getServiceLocator() instead * * @return ServiceManager * @throws InvalidServiceManagerException * @deprecated New services must be registered using Dependency Injection Container */ public function getServiceManager() { $serviceManager = $this->getServiceLocator(); if ($serviceManager instanceof ServiceManager) { return $serviceManager; } $msg = is_null($serviceManager) ? 'ServiceLocator not initialized for ' . get_class($this) : 'Alternate service locator not compatible with getServiceManager() in ' . __CLASS__; throw new InvalidServiceManagerException($msg); } /** * Register a service through ServiceManager * * @param $serviceKey * @param ConfigurableService $service * @param bool $allowOverride * @throws \common_Exception * @deprecated New services must be registered using Dependency Injection Container */ public function registerService($serviceKey, ConfigurableService $service, $allowOverride = true) { if ($allowOverride || ! $this->getServiceLocator()->has($serviceKey)) { $this->getServiceManager()->register($serviceKey, $service); } } /** * Propagate service dependencies * * @param $service * @return mixed * @deprecated New services must be registered using Dependency Injection Container */ protected function propagate($service) { // Propagate the service manager if ($service instanceof ServiceLocatorAwareInterface) { $service->setServiceLocator($this->getServiceLocator()); } // Propagate the logger service if ($service instanceof LoggerAwareInterface) { $logger = null; if ($this instanceof TaoLoggerAwareInterface) { $logger = $this->getLogger(); } else { if ($this->getServiceLocator()->has(LoggerService::SERVICE_ID)) { $logger = $this->getServiceLocator()->get(LoggerService::SERVICE_ID); } } if (!is_null($logger)) { $service->setLogger($logger); } } return $service; } }