本文整理汇总了PHP中Zend\ServiceManager\ServiceLocatorInterface::setService方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceLocatorInterface::setService方法的具体用法?PHP ServiceLocatorInterface::setService怎么用?PHP ServiceLocatorInterface::setService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\ServiceManager\ServiceLocatorInterface
的用法示例。
在下文中一共展示了ServiceLocatorInterface::setService方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Set up service manager and database configuration.
*
* @see PHPUnit_Framework_TestCase::setUp()
*/
protected function setUp()
{
$serviceManagerConfig = new Config(['factories' => ['SphinxSearch\\Db\\Adapter\\Adapter' => 'SphinxSearch\\Db\\Adapter\\AdapterServiceFactory'], 'alias' => ['sphinxql' => 'SphinxSearch\\Db\\Adapter\\Adapter']]);
$this->serviceManager = new ServiceManager();
$serviceManagerConfig->configureServiceManager($this->serviceManager);
$this->serviceManager->setService('Config', ['sphinxql' => ['driver' => 'pdo_mysql']]);
}
示例2: setUp
public function setUp()
{
$this->serviceManager = new ServiceManager(new Config(array('factories' => array('SphinxSearch\\Db\\Adapter\\Adapter' => 'SphinxSearch\\Db\\Adapter\\AdapterServiceFactory'), 'aliases' => array('sphinxql' => 'SphinxSearch\\Db\\Adapter\\Adapter'))));
$this->serviceManager->setService('Config', array('sphinxql' => $this->config));
$this->adapter = $this->serviceManager->get('sphinxql');
$this->search = new Search($this->adapter);
$this->sql = $this->search->getSql();
}
示例3: setUp
public function setUp()
{
$serviceManagerConfig = new Config(['factories' => ['SphinxSearch\\Db\\Adapter\\Adapter' => 'SphinxSearch\\Db\\Adapter\\AdapterServiceFactory'], 'aliases' => ['sphinxql' => 'SphinxSearch\\Db\\Adapter\\Adapter']]);
$this->serviceManager = new ServiceManager();
$serviceManagerConfig->configureServiceManager($this->serviceManager);
$this->serviceManager->setService('Config', ['sphinxql' => $this->config]);
$this->adapter = $this->serviceManager->get('sphinxql');
$this->search = new Search($this->adapter);
$this->sql = $this->search->getSql();
}
示例4: setSiteAccess
public function setSiteAccess()
{
// init session
$this->serviceManager->get('session');
// set user context
$container = new Container('initialized');
$this->serviceManager->setService('user', new User($container->userId));
$this->siteAccess = SiteaccessFactory::factory($this->serviceManager, $this->routeMatch->getParam('context'));
return $this;
}
示例5: createService
/**
* @param ServiceLocatorInterface $serviceLocator
* @return MvcTranslator
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
// Assume that if a user has registered a service for the
// TranslatorInterface, it must be valid
if ($serviceLocator->has('Zend\\I18n\\Translator\\TranslatorInterface')) {
return new MvcTranslator($serviceLocator->get('Zend\\I18n\\Translator\\TranslatorInterface'));
}
// If ext/intl is not loaded, return a dummy translator
if (!extension_loaded('intl')) {
return new MvcTranslator(new DummyTranslator());
}
// Load a translator from configuration, if possible
if ($serviceLocator->has('Config')) {
$config = $serviceLocator->get('Config');
// 'translator' => false
if (array_key_exists('translator', $config) && $config['translator'] === false) {
return new MvcTranslator(new DummyTranslator());
}
// 'translator' => array( ... translator options ... )
if (array_key_exists('translator', $config) && (is_array($config['translator']) && !empty($config['translator']) || $config['translator'] instanceof Traversable)) {
$i18nTranslator = Translator::factory($config['translator']);
$serviceLocator->setService('Zend\\I18n\\Translator\\TranslatorInterface', $i18nTranslator);
return new MvcTranslator($i18nTranslator);
}
}
// For BC purposes (pre-2.3.0), use the I18n Translator
return new MvcTranslator(new Translator());
}
示例6: setUp
/**
* Set up service manager and database configuration.
*
* @see PHPUnit_Framework_TestCase::setUp()
*/
protected function setUp()
{
$sManagerConfig = new Config(['abstract_factories' => ['SphinxSearch\\Db\\Adapter\\AdapterAbstractServiceFactory']]);
$this->serviceManager = new ServiceManager();
$sManagerConfig->configureServiceManager($this->serviceManager);
$this->serviceManager->setService('Config', ['sphinxql' => ['adapters' => ['SphinxSearch\\Db\\Adapter\\One' => ['driver' => 'pdo_mysql'], 'SphinxSearch\\Db\\Adapter\\Two' => ['driver' => 'pdo_mysql']]]]);
}
示例7: setServiceLocator
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->services = $serviceLocator;
// adding cache service
if (!$this->services->has('cache')) {
$cache = new \BaseXMS\Cache\Storage\Adapter\Filesystem();
$cache->setOptions(array('cache_dir' => 'data/cache'));
$this->services->setService('cache', $cache);
}
}
示例8: setUp
/**
* Set up LoggerAbstractServiceFactory and loggers configuration.
*
* @see PHPUnit_Framework_TestCase::setUp()
*/
protected function setUp()
{
$this->serviceManager = new ServiceManager(new ServiceManagerConfig(array('abstract_factories' => array('Zend\\Log\\LoggerAbstractServiceFactory'))));
$this->serviceManager->setService('Config', array('log' => array('Application\\Frontend' => array(), 'Application\\Backend' => array())));
}
示例9: setUp
/**
* Set up service manager and database configuration.
*
* @see PHPUnit_Framework_TestCase::setUp()
*/
protected function setUp()
{
$this->serviceManager = new ServiceManager(new ServiceManagerConfig(array('abstract_factories' => array('Zend\\Db\\Adapter\\AdapterAbstractServiceFactory'))));
$this->serviceManager->setService('Config', array('db' => array('adapters' => array('Zend\\Db\\Adapter\\Writer' => array('driver' => 'mysqli'), 'Zend\\Db\\Adapter\\Reader' => array('driver' => 'mysqli')))));
}
示例10: setUp
/**
* Set up service manager and database configuration.
*
* @see PHPUnit_Framework_TestCase::setUp()
*/
protected function setUp()
{
$this->serviceManager = new ServiceManager(new Config(array('factories' => array('SphinxSearch\\Db\\Adapter\\Adapter' => 'SphinxSearch\\Db\\Adapter\\AdapterServiceFactory'), 'alias' => array('sphinxql' => 'SphinxSearch\\Db\\Adapter\\Adapter'))));
$this->serviceManager->setService('Config', array('sphinxql' => array('driver' => 'pdo_mysql')));
}
示例11: setUp
/**
* Set up service manager and database configuration.
*
* @see PHPUnit_Framework_TestCase::setUp()
*/
protected function setUp()
{
$this->serviceManager = new ServiceManager(new Config(array('abstract_factories' => array('SphinxSearch\\Db\\Adapter\\AdapterAbstractServiceFactory'))));
$this->serviceManager->setService('Config', array('sphinxql' => array('adapters' => array('SphinxSearch\\Db\\Adapter\\One' => array('driver' => 'pdo_mysql'), 'SphinxSearch\\Db\\Adapter\\Two' => array('driver' => 'pdo_mysql')))));
}