當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。