PHP SoapServer,我如何从类内访问我的实体管理器


PHP SoapServer, how can I access my entity manager from within the class?

我有一个SoapServer。这个soap服务器有一个类

$server = new 'SoapServer($this->wsdl_path, array('classmap' => $this->classmap));
$server->setClass('MyNamespace''MyBundle''Lib''MySoapMethods');

我有类MySoapMethods,它实际上包含正在执行的方法。

class MySoapMethods
{
  public function sendNotification(NotificationRequest $request) {}
}

正在进行的调用是sendNotification。我的问题是:如何在这里注入我的Doctrine的EntityManager ?我找不到任何方法,我真的很讨厌使用静态调用

http://www.php.net/manual/en/soapserver.setclass.php

你可以为setServer方法指定更多的参数,这些参数将传递给被调用类的构造函数。