2014-11-14 02:47:39 +00:00
|
|
|
<?php
|
|
|
|
namespace Westdc\Service;
|
|
|
|
|
|
|
|
use Zend\ServiceManager\ServiceManager as Zend_ServiceManager;
|
|
|
|
|
|
|
|
class ServiceManager {
|
|
|
|
|
2015-02-21 15:17:27 +00:00
|
|
|
private static $instance = NULL;
|
|
|
|
|
|
|
|
public static function getInstance()
|
|
|
|
{
|
|
|
|
|
|
|
|
if (self::$instance === null) {
|
|
|
|
self::$instance = new self;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self::$instance;
|
|
|
|
}
|
|
|
|
|
2014-11-14 02:47:39 +00:00
|
|
|
private $serviceManager;
|
|
|
|
|
2015-02-21 15:17:27 +00:00
|
|
|
private function __construct()
|
2014-11-14 02:47:39 +00:00
|
|
|
{
|
2014-12-27 16:03:41 +00:00
|
|
|
$this->serviceManager = new Zend_ServiceManager;
|
2014-11-14 02:47:39 +00:00
|
|
|
$this->serviceManager->addAbstractFactory(new ServiceFactory);
|
2014-12-18 15:38:46 +00:00
|
|
|
|
|
|
|
$configService = $this->serviceManager->get('ConfigService');
|
|
|
|
$invoked_services = $configService->get('service.invoked.ini');
|
|
|
|
|
|
|
|
foreach($invoked_services as $k=>$v) {
|
|
|
|
$this->serviceManager->setInvokableClass($k, $v);
|
|
|
|
}
|
2014-11-14 02:47:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function addKey($key,$value = "")
|
|
|
|
{
|
|
|
|
if(!empty($value))
|
|
|
|
$this->serviceManager->$key($value);
|
|
|
|
else
|
|
|
|
$this->serviceManager->$key();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setServiceManager(Zend_ServiceManager $service)
|
|
|
|
{
|
|
|
|
$this->serviceManager = $service;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getServiceManager()
|
|
|
|
{
|
|
|
|
return $this->serviceManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|