Я сгенерировал сущности и формы с помощью symfony и попытался создать простую форму.Но я получаю сообщение об ошибке, которое не могу устранить.
Попытка вызова неопределенного метода с именем "createQueryBuilder" класса "AppBundle \ Entity \ User".
Контроллер:
public function groupedit(Request $request) {
$group = new Group();
$form = $this->createForm(GroupType::class, $group);
$form->handleRequest($request);
return $this->render(
'form.html.twig', array('form', $form->createView())
);
}
Пользователь YML
AppBundle\Entity\User:
type: entity
repositoryClass: User
id:
id:
type: integer
generator:
strategy: AUTO
fields:
xxx
manyToMany:
mailForwarder:
targetEntity: AppBundle\Entity\MailForwarder
inversedBy: user
joinTable:
name: MailForwarderHasUser
joinColumns:
user_id:
referencedColumnName: id
nullable: false
inverseJoinColumns:
mail_forwarder_id:
referencedColumnName: id
nullable: false
group:
targetEntity: AppBundle\Entity\Group
mappedBy: user
Группа YML
AppBundle\Entity\Group:
type: entity
repositoryClass: AppBundle\Entity\Group
id:
id:
type: integer
generator:
strategy: AUTO
fields:
xx
oneToMany:
sharedMailbox:
targetEntity: AppBundle\Entity\SharedMailbox
mappedBy: group
manyToMany:
user:
targetEntity: AppBundle\Entity\User
inversedBy: group
joinTable:
name: UserHasGroup
joinColumns:
group_id:
referencedColumnName: id
nullable: false
inverseJoinColumns:
user_id:
referencedColumnName: id
nullable: false
Пользовательский объект
class User implements UserInterface, \Serializable
{
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $mailForwarder;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $group;
xxx
/**
* Add mailForwarder
*
* @param \AppBundle\Entity\MailForwarder $mailForwarder
*
* @return User
*/
public function addMailForwarder(\AppBundle\Entity\MailForwarder $mailForwarder)
{
$this->mailForwarder[] = $mailForwarder;
return $this;
}
/**
* Remove mailForwarder
*
* @param \AppBundle\Entity\MailForwarder $mailForwarder
*/
public function removeMailForwarder(\AppBundle\Entity\MailForwarder $mailForwarder)
{
$this->mailForwarder->removeElement($mailForwarder);
}
/**
* Get mailForwarder
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getMailForwarder()
{
return $this->mailForwarder;
}
/**
* Add group
*
* @param \AppBundle\Entity\Group $group
*
* @return User
*/
public function addGroup(\AppBundle\Entity\Group $group)
{
$this->group[] = $group;
return $this;
}
/**
* Remove group
*
* @param \AppBundle\Entity\Group $group
*/
public function removeGroup(\AppBundle\Entity\Group $group)
{
$this->group->removeElement($group);
}
/**
* Get group
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getGroup()
{
return $this->group;
}
}
Групповой объект
class Group
{
XXX
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $sharedMailbox;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $user;
XXX
/**
* Add sharedMailbox
*
* @param \AppBundle\Entity\SharedMailbox $sharedMailbox
*
* @return Group
*/
public function addSharedMailbox(\AppBundle\Entity\SharedMailbox $sharedMailbox)
{
$this->sharedMailbox[] = $sharedMailbox;
return $this;
}
/**
* Remove sharedMailbox
*
* @param \AppBundle\Entity\SharedMailbox $sharedMailbox
*/
public function removeSharedMailbox(\AppBundle\Entity\SharedMailbox $sharedMailbox)
{
$this->sharedMailbox->removeElement($sharedMailbox);
}
/**
* Get sharedMailbox
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getSharedMailbox()
{
return $this->sharedMailbox;
}
/**
* Add user
*
* @param \AppBundle\Entity\User $user
*
* @return Group
*/
public function addUser(\AppBundle\Entity\User $user)
{
$this->user[] = $user;
return $this;
}
/**
* Remove user
*
* @param \AppBundle\Entity\User $user
*/
public function removeUser(\AppBundle\Entity\User $user)
{
$this->user->removeElement($user);
}
/**
* Get user
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getUser()
{
return $this->user;
}
}
Тип формы группы
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class GroupType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name')->add('systemgroup')->add('user');
}/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\Group'
));
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'appbundle_group';
}
}
У кого-нибудь есть идея, в чем проблема?
С уважением,
Алекс