我想设置一个变量$ time到当前时间,然后按照这种格式设置日期:HH:mm:ss在日/月/年.
谁能帮助我在symfony中做到这一点?
我有关于存储库的问题:是否可以使用
$em = $this->getDoctrine()
->getEntityManager();
$range = $em->getRepository('***Bundle:entityA')
->find($id);
Run Code Online (Sandbox Code Playgroud)
在实体B的存储库????
我在两个实体A和B之间有多对多的关系.
所以加入表单时,为了增加entityA对entityB,我做了以下内容:
$builder
->add('entityAs', 'entity', array(
'class' => 'xxxBundle:EntityA',
'property' => 'name',
'multiple' => true,
));}
Run Code Online (Sandbox Code Playgroud)
一切都很好.
但是根据entityA的字段类型,我想有时将'multiple'设置为false,所以我正在做以下事情:
if($type=='a'){
$builder
->add('entityAs', 'entity', array(
'class' => 'xxxBundle:entityA',
'property' => 'name',
'multiple' => true,
));}
else {
$builder
->add('entityAs', 'entity', array(
'class' => 'xxxBundle:entityA',
'property' => 'name',
'multiple' => false,
));
}
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误:
Catchable Fatal Error: Argument 1 passed to Doctrine\Common\Collections\ArrayCollection::__construct() must be an array, object given, called in C:\wamp\www\Symfony\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php on line 519 and defined in C:\wamp\www\Symfony\vendor\doctrine\common\lib\Doctrine\Common\Collections\ArrayCollection.php line …Run Code Online (Sandbox Code Playgroud) 我有一个扩展fos用户包和另一个包的包.
我希望一旦用户通过身份验证,根据他的角色管理员或简单用户将他重定向到不同的视图.
我的问题是我找不到登录的控制器,我将从哪里进行重定向.
角色是User来自数据库的实体的属性.