"targetEntity" from another package in Symfony2.3

I would like to use the object in another "targetEntity" object, but it generated an error ...

Between this class:

namespace Tgb\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use Symfony\Component\Validator\Constraints as Assert; /** * Website * * @ORM\Table(name="core_website") * @ORM\Entity(repositoryClass="Tgb\CoreBundle\Entity\WebsiteRepository") */ class Website { /** * @var Tgb\BlogBunble\Entity\Blog * * @ORM\OneToOne(targetEntity="Tgb\BlogBunble\Entity\Blog", mappedBy="website") */ private $blog; 

And this one:

 namespace Tgb\BlogBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use Symfony\Component\Validator\Constraints as Assert; /** * Blog * * @ORM\Table(name="blog") * @ORM\Entity(repositoryClass="Tgb\BlogBundle\Entity\BlogRepository") */ class Blog { /** * @var Tgb\CoreBunble\Entity\Website * * @ORM\OneToOne(targetEntity="Tgb\CoreBunble\Entity\Website", inversedBy="blog", cascade={"persist", "merge"}) */ private $website; 

When I run the command line:

 sf doctrine:schema:update --force 

I get:

 [Doctrine\ORM\Mapping\MappingException] The target-entity Tgb\BlogBunble\Entity\Blog cannot be found in 'Tgb\CoreBundle\Entity\Website#blog'. 

Any suggestions?

+4
source share
1 answer

You made a mistake in a bunch in several places:

  /** * @var Tgb\BlogBunble\Entity\Blog * * @ORM\OneToOne(targetEntity="Tgb\BlogBunble\Entity\Blog", mappedBy="website") */ private $blog; 

... and here:

  /** * @var Tgb\CoreBunble\Entity\Website * * @ORM\OneToOne(targetEntity="Tgb\CoreBunble\Entity\Website", inversedBy="blog", cascade={"persist", "merge"}) */ private $website; 

Replace BlogBunble with BlogBundle and CoreBunble with CoreBundle

+5
source

Source: https://habr.com/ru/post/1493733/


All Articles