I have been developing a project in zend 1 but decided to move over to zend 2 to take advantages of things like events etc.
My initial problem is that I can't seem to find any tutorials on how to use models in the way I need to use them.
What I have is an Api controller which is routed to as /api/soap
this soap endpoint loads a class that has all the methods I want to expose via SOAP
namespace MyProject\Controller;
$view = new ViewModel();
$view->setTerminal(true);
$view->setTemplate('index');
$endpoint = new EndpointController();
$server = new Server(
null, array('uri' => 'http://api.infinity-mcm.co.uk/api/soap')
);
$server->setObject($endpoint);
$server->handle();
and my controller that contains all the functions is
namespace MyProject\Controller;
class EndpointController
{
public function addSimpleProducts($products)
{
}
}
Now what I want to be able to do is access my products model from inside this EndpointController.
So i've tried this:
protected function getProductsTable()
{
if (!$this->productsTable) {
$sm = $this->getServiceLocator();
$this->productsTable= $sm->get('MyProject\Model\ProductsTable');
}
return $this->productsTable;
}
When I run this I get the fatal error that EndpointController::getServiceLocator() is undefined.
I am very new to Zend 2 but in Zend 1 it feels like this would be a very minor step in my development and im getting to the point of sacking zend 2 off and going back to zend 1 or even switching to symfony 2 where its simple to use doctrine...
help?