当前位置: 首页>>代码示例>>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;未经允许,请勿转载。