What you are looking at is the concept of Dependency Injection
. Basically YOU need to make sure that the Services you create GAIN access to the Gateways or Services they need.
For example, if you have a Service that takes care about persisting your Entities (DataObjects) to the Database, then YOU need to make sure to "inject" the Database-Adapter into the ServiceObject.
Required Dependencies therefore should be set via Constructor injection, i.e.:
class MyService {
public function __construct(DbAdapter $dbA) {
// do stuff with $dbA
}
}
And you create this via the ServiceManager
'service_manager' => array(
'factories' => array(
'MyService' => function($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$service = new MyService($dbAdapter);
return $service;
}
)
)
And lastly you access your service via the ServiceManager (probably somewhere in your controller).
public function someAction() {
$service = $this->getServiceLocator()->get('MyService');
// do stuff with $service
}