来自Symfony2.3中另一个包的"targetEntity"

aps*_*one 5 symfony doctrine-orm

我想在另一个包"targetEntity"属性中使用一个实体,但它生成错误...

在这堂课之间:

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;
Run Code Online (Sandbox Code Playgroud)

还有这个 :

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;
Run Code Online (Sandbox Code Playgroud)

当我运行line命令时:

sf doctrine:schema:update --force
Run Code Online (Sandbox Code Playgroud)

我明白了:

[Doctrine\ORM\Mapping\MappingException]                                                                
  The target-entity Tgb\BlogBunble\Entity\Blog cannot be found in 'Tgb\CoreBundle\Entity\Website#blog'.  
Run Code Online (Sandbox Code Playgroud)

有什么建议 ?

Pie*_*eau 6

你在几个地方拼错了包:

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

...和这里:

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

更换BlogBunbleBlogBundle并且CoreBunble通过CoreBundle