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


PHP ServiceManager::has方法代码示例

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


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

示例1: testHasServiceWithoutConfig

 public function testHasServiceWithoutConfig()
 {
     $this->serviceManager = new ServiceManager\ServiceManager(new ServiceManagerConfig(['abstract_factories' => ['AclMan\\Storage\\StorageFactory']]));
     $this->assertFalse($this->serviceManager->has('AclStorage'));
     $this->serviceManager = new ServiceManager\ServiceManager(new ServiceManagerConfig(['abstract_factories' => ['AclMan\\Storage\\StorageFactory']]));
     $this->serviceManager->setService('Config', []);
     $this->assertFalse($this->serviceManager->has('AclStorage'));
 }
开发者ID:ripaclub,项目名称:aclman,代码行数:8,代码来源:StorageFactoryTest.php

示例2: testMongoAdapterAbstractServiceFactorEmptyConfig

 public function testMongoAdapterAbstractServiceFactorEmptyConfig()
 {
     $this->serviceManager = new ServiceManager\ServiceManager(new ServiceManagerConfig(['abstract_factories' => ['ImgMan\\Storage\\Adapter\\Mongo\\MongoAdapterAbstractServiceFactory', 'ImgMan\\Storage\\Adapter\\Mongo\\MongoDbAbstractServiceFactory']]));
     $this->assertFalse($this->serviceManager->has('ImgMan\\Storage\\Mongo'));
     $this->serviceManager = new ServiceManager\ServiceManager(new ServiceManagerConfig(['abstract_factories' => ['ImgMan\\Storage\\Adapter\\Mongo\\MongoAdapterAbstractServiceFactory', 'ImgMan\\Storage\\Adapter\\Mongo\\MongoDbAbstractServiceFactory']]));
     $this->serviceManager->setService('Config', []);
     $this->assertFalse($this->serviceManager->has('ImgMan\\Storage\\Mongo'));
 }
开发者ID:ripaclub,项目名称:imgman,代码行数:8,代码来源:MongoAdapterAbstractServiceFactoryTest.php

示例3: testEmptyConfig

 public function testEmptyConfig()
 {
     $this->serviceManager = new ServiceManager\ServiceManager(new ServiceManagerConfig(['abstract_factories' => ['ImgMan\\Apigility\\ImgManConnectedResourceAbstractFactory']]));
     $this->assertFalse($this->serviceManager->has('ImgmanApigility\\ConnectedResource1'));
     $this->serviceManager = new ServiceManager\ServiceManager(new ServiceManagerConfig(['abstract_factories' => ['ImgMan\\Apigility\\ImgManConnectedResourceAbstractFactory']]));
     $this->serviceManager->setService('Config', []);
     $this->assertFalse($this->serviceManager->has('ImgmanApigility\\ConnectedResource1'));
 }
开发者ID:ripaclub,项目名称:zf-apigility-imgman,代码行数:8,代码来源:ImgManConnectedResourceAbstractFactoryTest.php

示例4: testCreateService

 public function testCreateService()
 {
     $config = ['mailman' => ['Mandrill\\Complete' => ['default_sender' => 'test@mail.com', 'additional_info' => ['some' => 'thing'], 'transport' => ['type' => 'mandrill', 'options' => ['api_key' => 'MYSECRETMANDRILLKEY', 'sub_account' => 'my-optional-subaccount-if-any']]]]];
     $this->sManager->setService('Config', $config);
     $this->assertTrue($this->sManager->has('Mandrill\\Complete'));
     $mailService = $this->sManager->get('Mandrill\\Complete');
     $this->assertInstanceOf('MailMan\\Service\\MailService', $mailService);
 }
开发者ID:ripaclub,项目名称:zf2-mailman,代码行数:8,代码来源:ServiceAbstractFactoryTest.php

示例5: testServiceIntegrity

 /**
  * Check if all configured services can be created
  *
  * @dataProvider provideServicesToCheck
  */
 public function testServiceIntegrity($serviceName)
 {
     $this->assertTrue(self::$serviceManager->has($serviceName));
     $object = self::$serviceManager->get($serviceName);
     if (class_exists($serviceName)) {
         $this->assertInstanceOf($serviceName, $object);
     }
 }
开发者ID:mtymek,项目名称:blast-test-utils,代码行数:13,代码来源:ServiceIntegrityTestTrait.php

示例6: testMongoDbAbstractServiceFactory

 public function testMongoDbAbstractServiceFactory()
 {
     $this->assertTrue($this->serviceManager->has('MongoDb'));
     $this->assertInstanceOf('MongoDb', $this->serviceManager->get('MongoDb'));
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(['abstract_factories' => ['ImgMan\\Storage\\Adapter\\Mongo\\MongoDbAbstractServiceFactory']]));
     $this->assertFalse($this->serviceManager->has('MongoDb'));
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(['abstract_factories' => ['ImgMan\\Storage\\Adapter\\Mongo\\MongoDbAbstractServiceFactory']]));
     $this->serviceManager->setService('Config', []);
     $this->assertFalse($this->serviceManager->has('MongoDb'));
 }
开发者ID:ripaclub,项目名称:imgman,代码行数:10,代码来源:MongoDbAbstractServiceFactoryTest.php

示例7: testFileSystemAbstractFactoryService

 public function testFileSystemAbstractFactoryService()
 {
     $this->assertTrue($this->serviceManager->has('ImgMan\\Storage\\FileSystem'));
     $this->assertInstanceOf('ImgMan\\Storage\\StorageInterface', $this->serviceManager->get('ImgMan\\Storage\\FileSystem'));
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(['abstract_factories' => ['ImgMan\\Storage\\Adapter\\FileSystem\\FileSystemAbstractServiceFactory']]));
     $this->assertFalse($this->serviceManager->has('ImgMan\\Storage\\FileSystem'));
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(['abstract_factories' => ['ImgMan\\Storage\\Adapter\\FileSystem\\FileSystemAbstractServiceFactory']]));
     $this->serviceManager->setService('Config', []);
     $this->assertFalse($this->serviceManager->has('ImgMan\\Storage\\FileSystem'));
 }
开发者ID:ripaclub,项目名称:imgman,代码行数:10,代码来源:FileSystemAbstractFactoryServiceTest.php

示例8: testServiceFactoryHas

 public function testServiceFactoryHas()
 {
     $serviceLocator = $this->serviceManager;
     $this->assertFalse($serviceLocator->has('ImgMan\\Service\\Test0'));
     $this->assertTrue($serviceLocator->has('ImgMan\\Service\\Test1'));
     $this->assertTrue($serviceLocator->has('ImgMan\\Service\\Test2'));
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(['abstract_factories' => ['ImgMan\\Service\\ImageServiceAbstractFactory']]));
     $this->assertFalse($this->serviceManager->has('ImgMan\\Service\\Test2'));
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(['abstract_factories' => ['ImgMan\\Service\\ImageServiceAbstractFactory']]));
     $this->serviceManager->setService('Config', []);
     $this->assertFalse($this->serviceManager->has('ImgMan\\Service\\Test2'));
 }
开发者ID:ripaclub,项目名称:imgman,代码行数:12,代码来源:ImageServiceFactoryTest.php

示例9: testBootstrapRecognizesServiceLocatorConfig

 public function testBootstrapRecognizesServiceLocatorConfig()
 {
     $eventPublisher = $this->getMockBuilder(ServiceLocatorAwareEventPublisher::CLASS)->disableOriginalConstructor()->getMock();
     $serviceLocator = new ServiceManager();
     $domainManager = new DomainManager($eventPublisher, $serviceLocator);
     $domainManager->registerDomain(new ExampleDomain());
     $domainManager->bootstrap();
     $this->assertTrue($serviceLocator->has('exampleAlias'));
     $this->assertEquals('exampleService', call_user_func($serviceLocator->get('exampleAlias')));
     $this->assertTrue($serviceLocator->has('exampleFactory'));
     $this->assertEquals('exampleFactory', $serviceLocator->get('exampleFactory'));
     $this->assertTrue($serviceLocator->has('exampleService'));
     $this->assertEquals('exampleService', call_user_func($serviceLocator->get('exampleService')));
 }
开发者ID:palya-framework,项目名称:palya,代码行数:14,代码来源:DomainManagerTest.php

示例10: getObjectManager

 /**
  * getObjectManager
  *
  * Return the object manager instance.
  *
  * @param ServiceManager  $serviceManager     The service manager.
  * @param string          $objectManagerName  The object manager name.
  * @param string          $serviceName        The name of the service being created.
  *
  * @return ObjectManager
  */
 private function getObjectManager(ServiceManager $serviceManager, $objectManagerName, $serviceName)
 {
     if (!$serviceManager->has($objectManagerName)) {
         throw new ServiceNotFoundException(sprintf('The object manager \'%s\' could not be found while creating \'%s\'.', $objectManagerName, $serviceName));
     }
     return $serviceManager->get($objectManagerName);
 }
开发者ID:alex-patterson-webdev,项目名称:arp-entity-repository,代码行数:18,代码来源:RepositoryAdapterFactory.php

示例11: onLoadModulesPost

 /**
  * Use merged configuration to configure service manager
  *
  * If the merged configuration has a non-empty, array 'service_manager'
  * key, it will be passed to a ServiceManager Config object, and
  * used to configure the service manager.
  *
  * @param  ModuleEvent $e
  * @throws Exception\RuntimeException
  * @return void
  */
 public function onLoadModulesPost(ModuleEvent $e)
 {
     $configListener = $e->getConfigListener();
     $config = $configListener->getMergedConfig(false);
     foreach ($this->serviceManagers as $key => $sm) {
         $smConfig = $this->mergeServiceConfiguration($key, $sm, $config);
         if (!$sm['service_manager'] instanceof ServiceManager) {
             if (!$this->defaultServiceManager->has($sm['service_manager'])) {
                 throw new Exception\RuntimeException(sprintf('Could not find a valid ServiceManager for %s', $sm['service_manager']));
             }
             $instance = $this->defaultServiceManager->get($sm['service_manager']);
             if (!$instance instanceof ServiceManager) {
                 throw new Exception\RuntimeException(sprintf('Could not find a valid ServiceManager for %s', $sm['service_manager']));
             }
             $sm['service_manager'] = $instance;
         }
         $serviceConfig = new ServiceConfig($smConfig);
         // The service listener is meant to operate during bootstrap, and, as such,
         // needs to be able to override existing configuration.
         $allowOverride = $sm['service_manager']->getAllowOverride();
         $sm['service_manager']->setAllowOverride(true);
         $serviceConfig->configureServiceManager($sm['service_manager']);
         $sm['service_manager']->setAllowOverride($allowOverride);
     }
 }
开发者ID:zendframework,项目名称:zend-modulemanager,代码行数:36,代码来源:ServiceListener.php

示例12: has

 public function has($name, $checkAbstractFactories = true, $usePeeringServiceManagers = true)
 {
     if (is_string($name)) {
         // internally called with an array [normalizedName, requestedName].
         $this->incrementCallCount('has', $name);
     }
     return parent::has($name, $checkAbstractFactories, $usePeeringServiceManagers);
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:8,代码来源:ServiceManagerMock.php

示例13: testCanonicalizeName

 /**
  * @covers Zend\ServiceManager\ServiceManager::canonicalizeName
  */
 public function testCanonicalizeName()
 {
     $this->serviceManager->setService('foo_bar', new \stdClass());
     $this->assertEquals(true, $this->serviceManager->has('foo_bar'));
     $this->assertEquals(true, $this->serviceManager->has('foobar'));
     $this->assertEquals(true, $this->serviceManager->has('foo-bar'));
     $this->assertEquals(true, $this->serviceManager->has('foo/bar'));
     $this->assertEquals(true, $this->serviceManager->has('foo bar'));
 }
开发者ID:benivaldo,项目名称:zf2-na-pratica,代码行数:12,代码来源:ServiceManagerTest.php

示例14: has

 public function has($name)
 {
     if (parent::has($name)) {
         return true;
     }
     if (preg_match('/doctrine/i', $name)) {
         return $this->serviceManager->has($name);
     }
     return false;
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:10,代码来源:PersistentServiceManager.php

示例15: testDiAbstractServiceFactory

 public function testDiAbstractServiceFactory()
 {
     $di = $this->getMock('Zend\\Di\\Di');
     $factory = new DiAbstractServiceFactory($di);
     $factory->instanceManager()->setConfig('ZendTest\\ServiceManager\\TestAsset\\Bar', array('parameters' => array('foo' => array('a'))));
     $this->serviceManager->addAbstractFactory($factory);
     $this->assertTrue($this->serviceManager->has('ZendTest\\ServiceManager\\TestAsset\\Bar', true));
     $bar = $this->serviceManager->get('ZendTest\\ServiceManager\\TestAsset\\Bar', true);
     $this->assertInstanceOf('ZendTest\\ServiceManager\\TestAsset\\Bar', $bar);
 }
开发者ID:Rovak,项目名称:zf2,代码行数:10,代码来源:ServiceManagerTest.php


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