Sonata Advanced Class Annotations Not Readable

I expanded the custom package from the Sonata project using the Sonata EasyExtends package. By default, it is under the name src / Application / Sonata / UserBundle.

Now I want to configure an extended class and add some fields. I noticed that annotations are not being processed, I need to define mappings in src / Application / Sonata / UserBundle / Resources / config / doctrine / User.orm.xml

Can annotations be used instead of an XML file? I think this will solve many of my problems with a reference to the user class, since now the command

php app / console doctrine: schema: update --force

doesn't seem to recognize annotations.

+6
source share
2 answers

Delete application / Sonata / UserBundle / Resources / config / doctrine first

and then change Entity / User.php and Entity / Group.php to annotation type:

<?php namespace Application\Sonata\UserBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Sonata\UserBundle\Entity\BaseUser as BaseUser; /** * User * * @ORM\Table(name="fos_user_user") * @ORM\Entity */ class User extends BaseUser { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @ORM\Column(type="string", length=127) */ protected $test; } 
 <?php namespace Application\Sonata\UserBundle\Entity; use Sonata\UserBundle\Entity\BaseGroup as BaseGroup; use Doctrine\ORM\Mapping as ORM; /** * Group * * @ORM\Table(name="fos_user_group") * @ORM\Entity */ class Group extends BaseGroup { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; } 

At the end, you should enter: php app / console doctrine: schema: update --force, and everything should work beautifully.

+10
source

In summary, if you use XML, annotations are not rules.

If you delete the config / doctrine folder, it will look for annotations, and there you can put what you want.

-1
source

All Articles