当前位置: 首页>>代码示例>>PHP>>正文


PHP ServiceManager::setAlias方法代码示例

本文整理汇总了PHP中Zend\ServiceManager\ServiceManager::setAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceManager::setAlias方法的具体用法?PHP ServiceManager::setAlias怎么用?PHP ServiceManager::setAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\ServiceManager\ServiceManager的用法示例。


在下文中一共展示了ServiceManager::setAlias方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createServiceManager

 public function createServiceManager($config)
 {
     $serviceManager = new ServiceManager();
     $serviceManager->setService('Configuration', $config);
     $serviceManager->setAlias('Config', 'Configuration');
     return $serviceManager;
 }
开发者ID:rhysr,项目名称:zf2assetic,代码行数:7,代码来源:AssetManifestFactoryTest.php

示例2: setup

 public function setup()
 {
     $this->config = new ArrayObject(array('diagnostics' => array()));
     $this->sm = new ServiceManager();
     $this->sm->setService('console', new ConsoleAdapter());
     $this->sm->setService('config', $this->config);
     $this->sm->setAlias('configuration', 'config');
     $this->mm = new InjectableModuleManager();
     $this->sm->setService('modulemanager', $this->mm);
     $event = new MvcEvent();
     $this->routeMatch = new RouteMatch(array('controller' => 'ZFTools\\Controller\\Diagnostics', 'action' => 'run'));
     $event->setRouteMatch($this->routeMatch);
     $this->controller = new DiagnosticsController();
     $this->controller->setServiceLocator($this->sm);
     $this->controller->setEvent($event);
 }
开发者ID:ralfeggert,项目名称:zftool,代码行数:16,代码来源:DiagnosticsControllerTest.php

示例3: testHasAlias

 /**
  * @covers Zend\ServiceManager\ServiceManager::hasAlias
  */
 public function testHasAlias()
 {
     $this->assertFalse($this->serviceManager->hasAlias('foo'));
     $this->serviceManager->setService('bar', 'baz');
     $this->serviceManager->setAlias('foo', 'bar');
     $this->assertTrue($this->serviceManager->hasAlias('foo'));
 }
开发者ID:rikaix,项目名称:zf2,代码行数:10,代码来源:ServiceManagerTest.php

示例4: getRouteNotFoundStrategy

 /**
  * Instantiates and configures the "route not found", or 404, strategy
  *
  * @return RouteNotFoundStrategy
  */
 public function getRouteNotFoundStrategy()
 {
     if ($this->routeNotFoundStrategy) {
         return $this->routeNotFoundStrategy;
     }
     $this->routeNotFoundStrategy = new RouteNotFoundStrategy();
     $displayExceptions = false;
     $displayNotFoundReason = false;
     $notFoundTemplate = '404';
     if (isset($this->config['display_exceptions'])) {
         $displayExceptions = $this->config['display_exceptions'];
     }
     if (isset($this->config['display_not_found_reason'])) {
         $displayNotFoundReason = $this->config['display_not_found_reason'];
     }
     if (isset($this->config['not_found_template'])) {
         $notFoundTemplate = $this->config['not_found_template'];
     }
     $this->routeNotFoundStrategy->setDisplayExceptions($displayExceptions);
     $this->routeNotFoundStrategy->setDisplayNotFoundReason($displayNotFoundReason);
     $this->routeNotFoundStrategy->setNotFoundTemplate($notFoundTemplate);
     $this->services->setService('RouteNotFoundStrategy', $this->routeNotFoundStrategy);
     $this->services->setAlias('Zend\\Mvc\\View\\RouteNotFoundStrategy', 'RouteNotFoundStrategy');
     $this->services->setAlias('Zend\\Mvc\\View\\Http\\RouteNotFoundStrategy', 'RouteNotFoundStrategy');
     $this->services->setAlias('404Strategy', 'RouteNotFoundStrategy');
     return $this->routeNotFoundStrategy;
 }
开发者ID:CHRISTOPHERVANDOMME,项目名称:zf2complet,代码行数:32,代码来源:ViewManager.php

示例5: testGet

 public function testGet()
 {
     // Via container
     $this->container->foo = [];
     $this->assertEquals([], $this->container->get('foo'));
     // Via service manager
     $this->sm->setService('foo', new \stdClass());
     $this->sm->setAlias('bar', 'foo');
     $this->assertInstanceOf('stdClass', $this->container->get('bar'));
     $this->sm->setFactory('factory', function (ServiceManager $sm) {
         return $sm->get('bar');
     });
     $this->assertInstanceOf('stdClass', $this->container->get('factory'));
     $this->sm->setInvokableClass('invokable', 'stdClass');
     $this->assertInstanceOf('stdClass', $this->container->get('invokable'));
 }
开发者ID:acelaya,项目名称:slim-container-sm,代码行数:16,代码来源:ContainerTest.php

示例6: createServiceManager

 protected function createServiceManager(array $config)
 {
     $serviceManager = new ServiceManager(new Config($config));
     $serviceManager->setService('Configuration', $config);
     $serviceManager->setAlias('Config', 'Configuration');
     return $serviceManager;
 }
开发者ID:rhysr,项目名称:zf2assetic,代码行数:7,代码来源:ContentTypeResolverFactoryTest.php

示例7: testCreateService

 /**
  * Test get SessionManager
  *
  * @expectedException PHPUnit_Framework_Error_Warning
  */
 public function testCreateService()
 {
     $serviceManager = new ServiceManager();
     $serviceFactory = new SessionManagerFactory();
     $serviceManager->setAlias('Configuration', 'Config')->setService('Config', array())->setService('Zend\\Session\\Storage\\StorageInterface', new ArrayStorage());
     $serviceFactory->createService($serviceManager);
 }
开发者ID:gridguyz,项目名称:zork,代码行数:12,代码来源:SessionManagerFactoryTest.php

示例8: initServiceManager

 /**
  * @param array $applicationConfig
  * @return ServiceManager
  */
 protected function initServiceManager(array $applicationConfig)
 {
     $smConfig = new Config(isset($applicationConfig['service_manager']) ? $applicationConfig['service_manager'] : []);
     $serviceManager = new ServiceManager($smConfig);
     $serviceManager->setService('Config', $applicationConfig);
     $serviceManager->setAlias('Configuration', 'Config');
     return $serviceManager;
 }
开发者ID:mtymek,项目名称:modular-expressive,代码行数:12,代码来源:ModularApplicationFactory.php

示例9: testCanGetAliasedServicesFromPeeringServiceManagers

 /**
  * @covers Zend\ServiceManager\ServiceManager::setAlias
  * @covers Zend\ServiceManager\ServiceManager::get
  * @covers Zend\ServiceManager\ServiceManager::retrieveFromPeeringManager
  */
 public function testCanGetAliasedServicesFromPeeringServiceManagers()
 {
     $service = new \stdClass();
     $peeringSm = new ServiceManager();
     $peeringSm->setService('actual-service-name', $service);
     $this->serviceManager->addPeeringServiceManager($peeringSm);
     $this->serviceManager->setAlias('alias-name', 'actual-service-name');
     $this->assertSame($service, $this->serviceManager->get('alias-name'));
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:14,代码来源:ServiceManagerTest.php

示例10: getZendMonitorExceptionStrategy

 /**
  * Instantiates and configures the Zend Monitor Exception strategy
  * @return \Zend\Mvc\View\Http\ZendMonitorExceptionStrategy
  */
 public function getZendMonitorExceptionStrategy()
 {
     if ($this->zendMonitorExceptionStrategy) {
         return $this->zendMonitorExceptionStrategy;
     }
     $this->zendMonitorExceptionStrategy = new ZendMonitorExceptionStrategy();
     $this->services->setService('zendMonitorExceptionStrategy', $this->zendMonitorExceptionStrategy);
     $this->services->setAlias('Zend\\Mvc\\View\\Http\\ZendMonitorExceptionStrategy', 'ZendMonitorExceptionStrategy');
     return $this->zendMonitorExceptionStrategy;
 }
开发者ID:ruslan-g,项目名称:zf2,代码行数:14,代码来源:ViewManager.php

示例11: testCreateZendCache

 /**
  * @covers \DoctrineModule\Service\CacheFactory::createService
  * @group 547
  */
 public function testCreateZendCache()
 {
     $factory = new CacheFactory('phpunit');
     $serviceManager = new ServiceManager();
     $serviceManager->setAlias('Config', 'Configuration');
     $serviceManager->setService('Configuration', ['doctrine' => ['cache' => ['phpunit' => ['class' => 'DoctrineModule\\Cache\\ZendStorageCache', 'instance' => 'my-zend-cache', 'namespace' => 'DoctrineModule']]], 'caches' => ['my-zend-cache' => ['adapter' => ['name' => 'blackhole']]]]);
     $serviceManager->addAbstractFactory('Zend\\Cache\\Service\\StorageCacheAbstractServiceFactory');
     $cache = $factory->createService($serviceManager);
     $this->assertInstanceOf('DoctrineModule\\Cache\\ZendStorageCache', $cache);
 }
开发者ID:davidmintz,项目名称:DoctrineModule,代码行数:14,代码来源:CacheFactoryTest.php

示例12: createServiceManager

 public function createServiceManager($config)
 {
     $serviceManager = new ServiceManager();
     $serviceManager->setService('AsseticAssetManager', $this->assetManager);
     $serviceManager->setService('router', $this->router);
     $serviceManager->setService('Configuration', $config);
     $serviceManager->setAlias('Config', 'Configuration');
     $serviceManager->setService('AssetManifest', $this->createAssetManifest($config));
     return $serviceManager;
 }
开发者ID:rhysr,项目名称:zf2assetic,代码行数:10,代码来源:AssetPathFactoryTest.php

示例13: testAssignAliasWithExistingServiceName

 /**
  * @expectedException Zend\ServiceManager\Exception\InvalidServiceNameException
  */
 public function testAssignAliasWithExistingServiceName()
 {
     $this->serviceManager->setFactory('foo', 'ZendTest\\ServiceManager\\TestAsset\\FooFactory');
     $this->serviceManager->setFactory('bar', function ($sm) {
         return new Bar(array('a'));
     });
     $this->serviceManager->setAllowOverride(false);
     // should throw an exception because 'foo' already exists in the service manager
     $this->serviceManager->setAlias('foo', 'bar');
 }
开发者ID:Rovak,项目名称:zf2,代码行数:13,代码来源:ServiceManagerTest.php

示例14: configureServiceManager

 /**
  * Configure the provided service manager instance with the configuration
  * in this class.
  *
  * @param  ServiceManager $serviceManager
  * @return ServiceManager
  */
 public function configureServiceManager(ServiceManager $serviceManager)
 {
     foreach ($this->factories as $name => $factory) {
         $serviceManager->setFactory($name, $factory);
     }
     foreach ($this->aliases as $alias => $target) {
         $serviceManager->setAlias($alias, $target);
     }
     return $serviceManager;
 }
开发者ID:axelmdev,项目名称:ecommerce,代码行数:17,代码来源:HelperConfig.php

示例15: testCreateService

 /**
  * Test get SessionManager
  */
 public function testCreateService()
 {
     $serviceManager = new ServiceManager();
     $serviceFactory = new SessionConfigFactory();
     $serviceManager->setAlias('Zork\\Db\\SiteInfo', 'SiteInfo')->setAlias('Configuration', 'Config')->setService('Config', array('session_config' => array()))->setService('SiteInfo', new SiteInfo(array('domain' => 'example.com')));
     /* @var $service \Zend\Session\Config\ConfigInterface */
     $service = $serviceFactory->createService($serviceManager);
     $this->assertInstanceOf('Zend\\Session\\Config\\ConfigInterface', $service);
     $this->assertEquals('.example.com', $service->getCookieDomain());
 }
开发者ID:gridguyz,项目名称:zork,代码行数:13,代码来源:SessionConfigFactoryTest.php


注:本文中的Zend\ServiceManager\ServiceManager::setAlias方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。