将ServiceManager修改为单例模式,修改几处ServiceManager调用
This commit is contained in:
parent
d668cc6aa4
commit
dee53af2fc
|
@ -54,6 +54,7 @@ class Dbh
|
|||
}
|
||||
}else{
|
||||
$sql = "INSERT INTO \"".$table."\" ($fields) VALUES ($datas) RETURNING id";
|
||||
//exit($sql);
|
||||
try{
|
||||
$sth = $this->db->prepare($sql);
|
||||
if($sth->execute())
|
||||
|
|
|
@ -14,7 +14,7 @@ class DefaultFileUploadListener implements ListenerAggregateInterface
|
|||
|
||||
function __construct()
|
||||
{
|
||||
$this->serviceManager = new ServiceManager();
|
||||
$this->serviceManager = ServiceManager::getInstance();
|
||||
$this->serviceManager = $this->serviceManager->getServiceManager();
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class Mail extends AbstractEventManager implements ServiceManagerAwareInterface{
|
|||
{
|
||||
if(!$this->serviceManager instanceof ServiceManager)
|
||||
{
|
||||
$serviceManager = new WestdcServiceManager();
|
||||
$serviceManager = WestdcServiceManager::getInstance();
|
||||
$this->serviceManager = $serviceManager->getServiceManager();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class Sender implements ServiceManagerAwareInterface{
|
|||
{
|
||||
if(!$this->serviceManager instanceof ServiceManager)
|
||||
{
|
||||
$serviceManager = new WestdcServiceManager();
|
||||
$serviceManager = WestdcServiceManager::getInstance();
|
||||
$this->serviceManager = $serviceManager->getServiceManager();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2014/11/11
|
||||
* Time: 11:12
|
||||
*/
|
||||
|
||||
namespace Westdc\Service;
|
||||
|
||||
use Zend\ServiceManager\ServiceManager as Zend_ServiceManager;
|
||||
|
||||
class ServiceManager {
|
||||
|
||||
private static $instance = NULL;
|
||||
|
||||
public static function getInstance()
|
||||
{
|
||||
|
||||
if (self::$instance === null) {
|
||||
self::$instance = new self;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
private $serviceManager;
|
||||
|
||||
function __construct()
|
||||
private function __construct()
|
||||
{
|
||||
$this->serviceManager = new Zend_ServiceManager;
|
||||
$this->serviceManager->addAbstractFactory(new ServiceFactory);
|
||||
|
|
Loading…
Reference in New Issue