简体   繁体   English

无法确定类“ AppBundle \\ Entity \\”中属性“ skills”的访问类型

[英]Could not determine access type for property “skills” in class “AppBundle\Entity\”

I make mapping manytomany in 2 entites but I have this error: 我在2个实体中映射了manytomany,但出现此错误:

Could not determine access type for property "skills" in class "AppBundle\\Entity\\". 无法确定类“ AppBundle \\ Entity \\”中属性“ skills”的访问类型。

code entity company: 代码实体公司:

/**
           * @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;
          }

code entity skill: 代码实体技能:

/**
                * @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;
               }

now i make functions of remove ,add and get variables in 2 entitys but I have also error and I initialize to arrayCollection 现在我在2个实体中执行remove,add和get变量的函数,但是我也有错误,我初始化为arrayCollection

函数名称应为addSkillremoveSkill而不带s

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在类“ App \\ Entity \\ GameGenre”中无法确定属性“游戏”的访问类型: - Could not determine access type for property “games” in class “App\Entity\GameGenre”: 无法确定 class “App\Entity\XXXX”中属性“image”的访问类型。 Symfony 4 - EasyAdmin 3.2 - VichUploader - Could not determine access type for property “image” in class “App\Entity\XXXX”. Symfony 4 - EasyAdmin 3.2 - VichUploader 错误:无法确定类“ Articles”中属性“ articlesCategories”的访问类型 - Error : Could not determine access type for property “articlesCategories” in class “Articles” Symfony错误(“可捕获的致命错误:Proxies__CG __ \\ AppBundle \\ Entity \\ Type类的对象无法转换为字符串”) - Symfony error (“Catchable Fatal Error: Object of class Proxies__CG__\AppBundle\Entity\Type could not be converted to string”) 无法确定属性“文件”的访问类型 - Could not determine access type for property "file" Symfony - 无法确定属性“id”的访问类型 - Symfony - Could not determine access type for property “id” 无法确定属性“ id”的访问类型-HandleRequest失败,除非我将实体ID公开 - Could not determine access type for property “id” - HandleRequest failing unless I make the entity id public 无法确定 class “App\Form\OrderType”中的属性“offerOrders”的访问类型:该属性都不是 - Could not determine access type for property “offerOrders” in class “App\Form\OrderType”: Neither the property 类AppBundle \\ Entity \\ Tarifa的对象无法转换为字符串 - Object of class AppBundle\Entity\Tarifa could not be converted to string 类 AppBundle\\Entity\\User 的对象无法转换为字符串 Symfony 3 - Object of class AppBundle\Entity\User could not be converted to string Symfony 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM