![](/img/trans.png)
[英]Could not determine access type for property “games” in class “App\Entity\GameGenre”:
[英]Could not determine access type for property “skills” in class “AppBundle\Entity\”
我在2個實體中映射了manytomany,但出現此錯誤:
無法確定類“ AppBundle \\ Entity \\”中屬性“ skills”的訪問類型。
代碼實體公司:
/**
* @var SkillInterface[]
*
* @ORM\ManyToMany(targetEntity="Skill", inversedBy="companys", cascade={"all"})
* @ORM\JoinTable(name="companys_has_skills",
* joinColumns={
* @ORM\JoinColumn(name="company_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="skill_id", referencedColumnName="id")
* }
* )
* @Assert\Count(min = 1)
*/
private $skills;
public function __construct()
{
$this->skills = new ArrayCollection();
}
/**
* Add skills.
*
* @param SkillInterface $skills
*
* @return Company
*/
public function addSkills(\AppBundle\Entity\Skill $skills)
{
$this->skills[] = $skills;
return $this;
}
/**
* Remove skills.
*
* @param SkillInterface $skills
*/
public function removeSkills(\AppBundle\Entity\Skill $skills)
{
$this->skills->removeElement($skills);
}
/**
* Get skills.
*
* @return Collection
*/
public function getSkills()
{
return $this->skills;
}
代碼實體技能:
/**
* @var Collection
*
* @ORM\ManyToMany(targetEntity="Company", mappedBy="skills")
*/
private $companys;
/**
* Constructor.
*/
public function __construct()
{
$this->companys = new ArrayCollection();
}
/**
* Add company.
*
* @param \AppBundle\Entity\Company $company
*
* @return Skill
*/
public function addCompany(\AppBundle\Entity\Company $company)
{
$this->companys[] = $company;
return $this;
}
/**
* Remove company.
*
* @param \AppBundle\Entity\Company $company
*/
public function removeCompany(\AppBundle\Entity\Company $company)
{
$this->companys->removeElement($company);
}
/**
* Get companys.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getCompanys()
{
return $this->companys;
}
現在我在2個實體中執行remove,add和get變量的函數,但是我也有錯誤,我初始化為arrayCollection
函數名稱應為addSkill
和removeSkill
而不帶s
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.