Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WebFactoryPolyClotBundle使用导致错误“;未找到字段';id';在课堂上';AppBundle\Entity\Film'&引用;_Php_Symfony_Doctrine Orm - Fatal编程技术网

Php WebFactoryPolyClotBundle使用导致错误“;未找到字段';id';在课堂上';AppBundle\Entity\Film'&引用;

Php WebFactoryPolyClotBundle使用导致错误“;未找到字段';id';在课堂上';AppBundle\Entity\Film'&引用;,php,symfony,doctrine-orm,Php,Symfony,Doctrine Orm,我使用Symfony版本3.4.0,并尝试使用此捆绑包翻译实体: 所以我为测试创建了两个实体(电影和电影翻译) 这里是我的Film.php <?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Webfactory\Bundle\PolyglotBundle\Annotation as Polyglot; use Webfactory\Bundle\PolyglotBundle\Translata

我使用Symfony版本3.4.0,并尝试使用此捆绑包翻译实体:

所以我为测试创建了两个实体(电影和电影翻译)

这里是我的Film.php

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

use Webfactory\Bundle\PolyglotBundle\Annotation as Polyglot;
use Webfactory\Bundle\PolyglotBundle\TranslatableInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * Film
 *
 * @ORM\Table(name="film")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\FilmRepository")
 * @Polyglot\Locale(primary="fr_FR")
 */
class Film
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @Polyglot\TranslationCollection
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="Titre", type="string", length=255, unique=true)
     * @Polyglot\Translatable
     * @var string|TranslatableInterface
     */
    private $titre;

    /**
     * @ORM\OneToMany(targetEntity="FilmTranslation", mappedBy="entity")
     * @Polyglot\TranslationCollection
     * @var Collection
     */
    private $translations;

    public function __construct()
    {
        $this->translations = new ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set titre
     *
     * @param string $titre
     *
     * @return Film
     */
    public function setTitre($titre)
    {
        $this->titre = $titre;

        return $this;
    }

    /**
     * Get titre
     *
     * @return string
     */
    public function getTitre()
    {
        return $this->titre;
    }

    /**
     * Add translation
     *
     * @param \AppBundle\Entity\FilmTranslation $translation
     *
     * @return Film
     */
    public function addTranslation(\AppBundle\Entity\FilmTranslation $translation)
    {
        $this->translations[] = $translation;

        return $this;
    }

    /**
     * Remove translation
     *
     * @param \AppBundle\Entity\FilmTranslation $translation
     */
    public function removeTranslation(\AppBundle\Entity\FilmTranslation $translation)
    {
        $this->translations->removeElement($translation);
    }

    /**
     * Get translations
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getTranslations()
    {
        return $this->translations;
    }
}


所以像这样从
$id
注释中删除
@Polyglot\TranslationCollection


为什么在
Film.php
中的
$id
注释中有
@Polyglot\TranslationCollection
?@qdequippe,因为这是我的错误。我不知道为什么我没有看到它。谢谢,现在一切都好了。
<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Webfactory\Bundle\PolyglotBundle\Entity\BaseTranslation;

/**
 * FilmTranslation
 *
 * @ORM\Table(name="film_translation")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\FilmTranslationRepository")
 * @ORM\Table(
 *      uniqueConstraints = {
 *          @ORM\UniqueConstraint(columns={"entity_id", "locale"})
 *     }
 * )
 */
class FilmTranslation extends BaseTranslation
{

    /**
     * @var string
     *
     * @ORM\Column(name="titre", type="string", length=255, unique=true)
     */
    private $titre;

    /**
     * @ORM\ManyToOne(targetEntity="Film", inversedBy="translations")
     * @var Film
     */
    protected $entity;

    /**
     * Set titre
     *
     * @param string $titre
     *
     * @return FilmTranslation
     */
    public function setTitre($titre)
    {
        $this->titre = $titre;

        return $this;
    }

    /**
     * Get titre
     *
     * @return string
     */
    public function getTitre()
    {
        return $this->titre;
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set locale
     *
     * @param string $locale
     *
     * @return FilmTranslation
     */
    public function setLocale($locale)
    {
        $this->locale = $locale;

        return $this;
    }

    /**
     * Set entity
     *
     * @param \AppBundle\Entity\Film $entity
     *
     * @return FilmTranslation
     */
    public function setEntity(\AppBundle\Entity\Film $entity = null)
    {
        $this->entity = $entity;

        return $this;
    }

    /**
     * Get entity
     *
     * @return \AppBundle\Entity\Film
     */
    public function getEntity()
    {
        return $this->entity;
    }
}

class Film
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;