I would like to use an entity in another bundle "targetEntity" property but it generated 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 line command :
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 ?
You mispelled bundle in a few 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
by BlogBundle
and CoreBunble
by CoreBundle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With