我有2个捆绑包。
捆绑1:
class EntityOne {
private $_foo;
public function setFoo($foo)
{
$this->_foo = $foo;
return $this;
}
public function getFoo()
{
return $this->_foo;
}
}
我的服务(service.yml)
service:
MyFooProject\Entity:
class: MyFooProject\Entity\EntityOne
捆绑2:
class EntityTwo extends \MyFooProject\Entity\EntityOne {
private $_bar;
public function setBar($bar)
{
$this->_bar = $bar;
return $this;
}
public function getBar()
{
return $this->_bar;
}
}
我的服务(service.yml)
service:
MyBarProject\Entity\EntityTwo
parent: MyFooProject\Entity\EntityOne
现在,我想在捆绑软件1中调用方法setBar()
,但是Symfony从捆绑软件2中找不到方法setBar()
function test()
{
$oEntity = $this->get(MyFooProject\Entity\EntityOne::class);
$oEntity->setFoo("foo");
$oEntity->setBar("bar"),
}
我该如何解决问题?