我是Symfony的新手,我对此进行了网络应用程序,在女巫中,用户与实体"任务"有关。它不起作用,因为我得到了错误
FatalErrorException: Error: Call to undefined method
AcmeManagementBundleEntityUserGroundStation::getMission()
te getermission是在传教士中定义的,并在结构中调用。我必须再次定义吗?我不明白。
我的用户是:
<?php
namespace AcmeManagementBundleEntity;
use DoctrineORMMapping as ORM;
use FOSUserBundleModelUser as BaseUser;
use DoctrineCommonCollectionsArrayCollection;
use DoctrineCommonCollectionsCollection;
/**
* @ORMEntity
* @ORMHasLifecycleCallbacks()
* @ORMTable(name="user")
* @ORMInheritanceType("JOINED")
* @ORMDiscriminatorColumn(name="type", type="string")
* @ORMDiscriminatorMap({"user_one" = "UserGroundStation", "user_two" = "UserOperator"})
* @ORMMappedSuperclass()
*
*/
abstract class User extends BaseUser
{
/**
* @ORMId
* @ORMColumn(type="integer")
* @ORMGeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORMManyToMany(targetEntity="AcmeManagementBundleEntityMission", mappedBy="users")
*/
protected $missions;
public function __construct(){
parent::__construct();
$this -> missions = new ArrayCollection();
}
public function setMissions(Collection $missions){
$this -> missions = $missions;
return $this;
}
public function addMission($mission){
$this -> missions -> add($mission);
return $this;
}
public function getMissions(){
return $this -> missions;
}
}
和任务实体是:
/**
* @ORMEntity
*/
class Mission {
/**
* @ORMId
* @ORMGeneratedValue
* @ORMColumn(type="integer")
* @var integer
*/
protected $id;
/**
* @ORMColumn(type="string", length=60)
* @var String
*/
protected $name;
/**
* @ORMColumn(type="string", length=600)
* @var String
*/
protected $description;
/**
* @ORMManyToMany(targetEntity="AcmeManagementBundleEntityUser", inversedBy="users")
*/
protected $users;
public function __construct(){
$this -> users = new ArrayCollection();
}
public function setUsers(Collection $users){
$this -> users = $users;
return $this;
}
public function addUser($user){
$this -> users -> add($user);
return $this;
}
public function getUsers(){
return $this -> users;
}
//setters and getters for id, name and description
}
如何解决这个问题?谢谢
您有一个错字:
getMission
而不是:
getMissions
,或者您肯定没有在任务实体中声明的方法,而您正在调用该方法的类也不是在列表中。确保它从用户继承。