當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ServiceManager\ServiceManager類代碼示例

本文整理匯總了PHP中Zend\ServiceManager\ServiceManager的典型用法代碼示例。如果您正苦於以下問題:PHP ServiceManager類的具體用法?PHP ServiceManager怎麽用?PHP ServiceManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ServiceManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: init

 public static function init()
 {
     // Load the user-defined test configuration file, if it exists; otherwise, load
     if (is_readable(__DIR__ . '/TestConfig.php')) {
         $testConfig = (include __DIR__ . '/TestConfig.php');
     } else {
         $testConfig = (include __DIR__ . '/TestConfig.php.dist');
     }
     $zf2ModulePaths = array();
     if (isset($testConfig['module_listener_options']['module_paths'])) {
         $modulePaths = $testConfig['module_listener_options']['module_paths'];
         foreach ($modulePaths as $modulePath) {
             if ($path = static::findParentPath($modulePath)) {
                 $zf2ModulePaths[] = $path;
             }
         }
     }
     $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
     $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
     static::initAutoloader();
     // use ModuleManager to load this module and it's dependencies
     $baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
     $config = ArrayUtils::merge($baseConfig, $testConfig);
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     static::$serviceManager = $serviceManager;
     static::$config = $config;
 }
開發者ID:gingerwfms,項目名稱:wf-configurator-backend,代碼行數:29,代碼來源:Bootstrap.php

示例2: testCreateService

 public function testCreateService()
 {
     $sm = new ServiceManager();
     $sm->setService('Acelaya\\Yaml\\View\\Renderer\\YamlRenderer', new YamlRenderer());
     $service = $this->factory->createService($sm);
     $this->assertInstanceOf('Acelaya\\Yaml\\View\\Strategy\\YamlStrategy', $service);
 }
開發者ID:acelaya,項目名稱:zf2-acyaml,代碼行數:7,代碼來源:YamlStrategyFactoryTest.php

示例3: setUp

 public function setUp()
 {
     $this->pluginManager = new RulePluginManager();
     $serviceManager = new ServiceManager();
     $serviceManager->setService('MvcTranslator', new Translator());
     $this->pluginManager->setServiceLocator($serviceManager);
 }
開發者ID:rettal,項目名稱:zf2-form,代碼行數:7,代碼來源:RulePluginManagerTest.php

示例4: get

 /**
  * Init an instance of QueueWriter and configure an internal instance of ServiceManager
  *
  * @param array $config
  * @return QueueWriterInterface
  */
 public static function get(array $config)
 {
     $serviceConfig = (include dirname(dirname(dirname(__DIR__))) . '/config/services.config.php');
     $services = new ServiceManager(new Config($serviceConfig['service_manager']));
     $services->setService("Config", $config);
     return $services->get('recommerce.queue-manager.queue-writer');
 }
開發者ID:recommerce,項目名稱:queue-manager,代碼行數:13,代碼來源:QueueWriterProvider.php

示例5: setUp

 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->doa = new Doa();
     $this->doa->setId(1);
     $program = new Program();
     $program->setId(1);
     $program->setProgram('Program');
     $this->doa->setProgram($program);
     $organisation = new Organisation();
     $organisation->setId(1);
     $organisation->setOrganisation("Organisation");
     $this->doa->setOrganisation($organisation);
     $this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize');
     if (!$this->authorizeService->getAcl()->hasResource($this->doa)) {
         $this->authorizeService->getAcl()->addResource($this->doa);
         $this->authorizeService->getAcl()->allow([], $this->doa, []);
     }
     /**
      * Add the resource on the fly
      */
     if (!$this->authorizeService->getAcl()->hasResource(new Doa())) {
         $this->authorizeService->getAcl()->addResource(new Doa());
     }
     $this->authorizeService->getAcl()->allow([], new Doa(), []);
     $this->doaLink = $this->serviceManager->get('viewhelpermanager')->get('programDoaLink');
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
開發者ID:debranova,項目名稱:program,代碼行數:35,代碼來源:DoaLinkTest.php

示例6: configureServiceManager

 public function configureServiceManager(\Zend\ServiceManager\ServiceManager $serviceManager)
 {
     $serviceManager->setFactory('A', function () {
         return new A();
     });
     $serviceManager->setShared('A', false);
 }
開發者ID:lucatume,項目名稱:php-dependency-injection-benchmarks,代碼行數:7,代碼來源:test2.php

示例7: testCreateService

 /**
  * @covers Hermes\Api\ClientFactory::createService
  */
 public function testCreateService()
 {
     $sm = new ServiceManager(new Config([]));
     $sm->setService('config', ['hermes' => ['uri' => 'http://localhost:8000', 'depth' => 0, 'headers' => [], 'http_client' => ['options' => []]]]);
     $client = $this->object->createService($sm);
     $this->assertInstanceOf(Client::class, $client);
 }
開發者ID:mt-olympus,項目名稱:hermes,代碼行數:10,代碼來源:ClientFactoryTest.php

示例8: testInvoke

 public function testInvoke()
 {
     $sm = new ServiceManager();
     $sm->setService('config', ['recaptcha' => ['private_key' => 'foo']]);
     $instance = $this->factory->__invoke($sm, '');
     $this->assertInstanceOf(ReCaptcha::class, $instance);
 }
開發者ID:acelaya,項目名稱:alejandrocelaya.com,代碼行數:7,代碼來源:RecaptchaFactoryTest.php

示例9: wp_authenticate

 public function wp_authenticate($hash, $password, ServiceManager $sm)
 {
     /** @var PasswordHash $wp_hasher */
     $wp_hasher = $sm->get('wp_hasher');
     $result = $wp_hasher->CheckPassword($password, $hash);
     return $result;
 }
開發者ID:binarykitten,項目名稱:zf2authwordpress,代碼行數:7,代碼來源:Module.php

示例10: getServiceLocator

 public function getServiceLocator(array $config = array())
 {
     $serviceLocator = new ServiceManager();
     $serviceLocator->setFactory('MQUtil\\Service\\ShortUrl', 'MQUtil\\Service\\ShortUrlFactory');
     $serviceLocator->setService('config', $config);
     return $serviceLocator;
 }
開發者ID:milqmedia,項目名稱:mq-util,代碼行數:7,代碼來源:ShortenUrlTest.php

示例11: init

 public static function init()
 {
     if (is_readable(__DIR__ . '/config.php')) {
         $testConfig = (include __DIR__ . '/config.php');
     } else {
         $testConfig = (include __DIR__ . '/config.php.dist');
     }
     $moduleName = pathinfo(realpath(dirname(__DIR__)), PATHINFO_BASENAME);
     if (defined('MODULE_NAME')) {
         $moduleName = MODULE_NAME;
     }
     $zf2ModulePaths = array(dirname(dirname(__DIR__)));
     if ($path = static::findParentPath('vendor')) {
         $modulePaths[] = $path;
     }
     if (($path = static::findParentPath('module')) !== $modulePaths[0]) {
         $modulePaths[] = $path;
     }
     if (isset($additionalModulePaths)) {
         $zf2ModulePaths = array_merge($modulePaths, $additionalModulePaths);
     } else {
         $zf2ModulePaths = $modulePaths;
     }
     $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
     static::initAutoloader();
     $baseConfig = ['module_listener_options' => ['module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)], 'modules' => [$moduleName]];
     $config = ArrayUtils::merge($baseConfig, $testConfig);
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     static::$serviceManager = $serviceManager;
 }
開發者ID:kedwards,項目名稱:knc-error,代碼行數:32,代碼來源:Bootstrap.php

示例12: setUp

 /**
  * Setup
  */
 protected function setUp()
 {
     // get service manager
     $this->serviceLocator = FileManagerBootstrap::getServiceLocator();
     // get base user model instance
     $this->userModel = $this->serviceLocator->get('Application\\Model\\ModelManager')->getInstance('User\\Model\\UserBase');
 }
開發者ID:esase,項目名稱:dream-cms,代碼行數:10,代碼來源:DeleteUserTest.php

示例13: setUp

 /**
  * Setup
  */
 protected function setUp()
 {
     // get service manager
     $this->serviceLocator = ApplicationBootstrap::getServiceLocator();
     // get base model instance
     $this->model = $this->serviceLocator->get('Application\\Model\\ModelManager')->getInstance('Application\\Model\\ApplicationBase');
 }
開發者ID:esase,項目名稱:dream-cms,代碼行數:10,代碼來源:ApplicationSlugTest.php

示例14: testCreateService

 public function testCreateService()
 {
     $this->sm->setService('Matryoshka\\Model\\Object\\ObjectManager', $this->om);
     $this->pm->setServiceLocator($this->sm);
     $object = $this->factory->createService($this->pm);
     $this->assertInstanceOf('Matryoshka\\Module\\Controller\\Plugin\\Object', $object);
 }
開發者ID:matryoshka-model,項目名稱:zf2-matryoshka-module,代碼行數:7,代碼來源:ObjectFactoryTest.php

示例15: noticeOfCreation

 /**
  * Sends the mail to user with info about successfull registration
  *
  * @param \User\Entity\User $user
  * @param string $password
  * @param string $siteName
  */
 public function noticeOfCreation(UserEntity $user, $password, $siteName, $actUrl = null)
 {
     $template = $this->storage->getByKey(2);
     $serverUrl = $this->serviceManager->get('ViewHelperManager')->get('serverUrl');
     $body = str_replace(array("[NAME]", "[SITENAME]", "[LOGINNAME]", "[PASSWORD]", "[SITEURL]", "[ACTIVATIONLINK]"), array($user->username, $siteName, $user->username, $password, $serverUrl(), sprintf('<a href="%s">%s</a>', $actUrl, $actUrl)), $template->emailBody);
     return $this->send($user->username, $template->emailSubject, $body);
 }
開發者ID:ponchov,項目名稱:teeforall,代碼行數:14,代碼來源:Mail.php


注:本文中的Zend\ServiceManager\ServiceManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。