Symfony 2.3 を使用していますが、プロジェクトを一覧表示しようとすると、次の例外が発生します。
The target-entity Weber\ProjectBundle\Entity\SurveyUrl cannot be found in 'Weber\ProjectBundle\Entity\Project#surveyUrls'.
私のエンティティの簡略化は次のとおりです。
Project.php:
<?php
namespace Weber\ProjectBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Project
*
* @ORM\Entity
*/
class Project
{
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\OneToMany(targetEntity="Respondent", mappedBy="project")
*/
protected $respondents;
/**
* @ORM\OneToMany(targetEntity="SurveyUrl", mappedBy="project")
*/
protected $surveyUrls;
/**
* Constructor
*/
public function __construct()
{
$this->respondents = new ArrayCollection();
$this->surveyUrls = new ArrayCollection();
}
/**
* Add respondents
*
* @param \Weber\ProjectBundle\Entity\Respondent $respondents
* @return Project
*/
public function addRespondent(\Weber\ProjectBundle\Entity\Respondent $respondents)
{
$this->respondents[] = $respondents;
return $this;
}
/**
* Remove respondents
*
* @param \Weber\ProjectBundle\Entity\Respondent $respondents
*/
public function removeRespondent(\Weber\ProjectBundle\Entity\Respondent $respondents)
{
$this->respondents->removeElement($respondents);
}
/**
* Get respondents
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getRespondents()
{
return $this->respondents;
}
/**
* Add surveyUrls
*
* @param \Weber\ProjectBundle\Entity\SurveyUrl $surveyUrls
* @return Project
*/
public function addSurveyUrl(\Weber\ProjectBundle\Entity\SurveyUrl $surveyUrls)
{
$this->surveyUrls[] = $surveyUrls;
return $this;
}
/**
* Remove surveyUrls
*
* @param \Weber\ProjectBundle\Entity\SurveyUrl $surveyUrls
*/
public function removeSurveyUrl(\Weber\ProjectBundle\Entity\SurveyUrl $surveyUrls)
{
$this->surveyUrls->removeElement($surveyUrls);
}
/**
* Get surveyUrls
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getSurveyUrls()
{
return $this->surveyUrls;
}
}
Respondent.php:
<?php
namespace Weber\ProjectBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Respondent
*
* @ORM\Entity
*/
class Respondent
{
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="Project")
*/
protected $project;
/**
* Set project
*
* @param \Weber\ProjectBundle\Entity\Project $project
* @return Respondent
*/
public function setProject(\Weber\ProjectBundle\Entity\Project $project = null)
{
$this->project = $project;
return $this;
}
/**
* Get project
*
* @return \Weber\ProjectBundle\Entity\Project
*/
public function getProject()
{
return $this->project;
}
}
およびSurveyUrl.php:
<?php
namespace Weber\ProjectBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* SurveyURL
*
* @ORM\Entity
*/
class SurveyURL
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* The project for this url.
*
* @ORM\ManyToOne(targetEntity="Project", inversedBy="surveyUrls")
* (I have also tried without 'inversedBy')
*/
protected $project;
/**
* May be null.
* The respondent that answered this survey.
*
* @ORM\OneToOne(targetEntity="Respondent")
*/
protected $respondent;
/**
* Set project
*
* @param \Weber\ProjectBundle\Entity\Project $project
* @return SurveyURL
*/
public function setProject(\Weber\ProjectBundle\Entity\Project $project = null)
{
$this->project = $project;
return $this;
}
/**
* Get project
*
* @return \Weber\ProjectBundle\Entity\Project
*/
public function getProject()
{
return $this->project;
}
/**
* Set respondent
*
* @param \Weber\ProjectBundle\Entity\Respondent $respondent
* @return SurveyURL
*/
public function setRespondent(\Weber\ProjectBundle\Entity\Respondent $respondent = null)
{
$this->respondent = $respondent;
return $this;
}
/**
* Get respondent
*
* @return \Weber\ProjectBundle\Entity\Respondent
*/
public function getRespondent()
{
return $this->respondent;
}
}
私が理解できないのは、SurveyUrl エンティティを作成する前はまったく問題がなく、両方のエンティティの構成がほぼ同じであるということです。
助けてくれてありがとう。