Search code examples
phpdoctrinesoapserver

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


I have a SoapServer. This soap server has a class

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

And I have the class MySoapMethods which actually contain the methods being executed.

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

The call being made is sendNotification. My question is: How can I inject my EntityManager of Doctrine in here? I can't find any method for this and I really hate using static calls for this.


Solution

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

    You can specify more arguments to the setServer method which will be passed to the constructor of the called class.