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


PHP Application::getServiceManager方法代码示例

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


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

示例1: __construct

 public function __construct($name = null, array $data = array(), $dataName = '')
 {
     parent::__construct($name, $data, $dataName);
     $this->app = \Bootstrap::$app;
     $this->sm = $this->app->getServiceManager();
     $this->evm = $this->app->getEventManager();
 }
开发者ID:ebittleman,项目名称:mailgun-zf2,代码行数:7,代码来源:UnitTest.php

示例2: initialize

 /**
  * {@inheritdoc}
  */
 public function initialize(ContextInterface $context)
 {
     if ($context instanceof ApplicationAwareInterface) {
         $context->setApplication($this->application);
     }
     if ($context instanceof ServiceLocatorAwareInterface) {
         $context->setServiceLocator($this->application->getServiceManager());
     }
 }
开发者ID:enlitepro,项目名称:enlite-behat-extension,代码行数:12,代码来源:ApplicationAwareInitializer.php

示例3: clearDatabase

 /**
  * @BeforeFeature
  */
 public static function clearDatabase()
 {
     $em = self::$zendApp->getServiceManager()->get('doctrine.entitymanager.orm_default');
     $q = $em->createQuery('delete from CargoBackend\\Model\\Cargo\\Cargo');
     $q->execute();
     $q = $em->createQuery('delete from CargoBackend\\Model\\Cargo\\RouteSpecification');
     $q->execute();
     $q = $em->createQuery('delete from CargoBackend\\Model\\Cargo\\Itinerary');
     $q->execute();
 }
开发者ID:pawelryznar,项目名称:php-ddd-cargo-sample,代码行数:13,代码来源:FeatureContext.php

示例4: getApplication

 /**
  * @return \Zend\Mvc\Application
  */
 public function getApplication()
 {
     if ($this->spiffyApplication) {
         return $this->spiffyApplication;
     }
     Console::overrideIsConsole($this->getUseConsoleRequest());
     $this->spiffyApplication = SpiffyTest::getInstance()->getApplication();
     $events = $this->spiffyApplication->getEventManager();
     $events->detach($this->spiffyApplication->getServiceManager()->get('SendResponseListener'));
     return $this->spiffyApplication;
 }
开发者ID:svenanders,项目名称:saruser,代码行数:14,代码来源:AbstractHttpControllerTestCase.php

示例5: applicationExists

 /**
  * @Then I should have the application
  */
 public function applicationExists(TableNode $table)
 {
     /** @var ApplicationManager $applicationManager */
     $applicationManager = self::$application->getServiceManager()->get('application/application-manager');
     $data = [];
     foreach ($table->getTable() as $row) {
         $data[$row[0]] = $row[1];
     }
     $application = $applicationManager->get($data['name']);
     \PHPUnit_Framework_Assert::assertInstanceOf('Continuous\\DeployAgent\\Application\\Application', $application);
     foreach ($data as $property => $value) {
         switch ($property) {
             case 'pipeline':
                 $property = 'reference';
             case 'token':
             case 'repositoryProvider':
             case 'repository':
                 \PHPUnit_Framework_Assert::assertAttributeEquals($value, $property, $application->getProvider());
                 break;
             case 'provider':
                 $provider = self::$application->getServiceManager()->get('provider/' . $value);
                 \PHPUnit_Framework_Assert::assertAttributeInstanceOf(get_class($provider), $property, $application);
                 break;
             default:
                 \PHPUnit_Framework_Assert::assertAttributeEquals($value, $property, $application);
         }
     }
 }
开发者ID:continuousphp,项目名称:deploy-agent,代码行数:31,代码来源:DeployAgentContext.php

示例6: setCatchExceptions

 /**
  * Adds a value to the ServiceManager to indicate if an exception must be
  * thrown or caught.
  *
  * @param boolean $catch
  * @return null
  */
 protected function setCatchExceptions($catch)
 {
     $serviceManager = $this->application->getServiceManager();
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('KernelCatchExceptions', $catch);
     $serviceManager->setAllowOverride(false);
 }
开发者ID:reenl,项目名称:stack-zf2,代码行数:14,代码来源:ZendHttpKernel.php

示例7: createDatabase

 public static function createDatabase(\Zend\Mvc\Application $application)
 {
     // build test database
     $entityManager = $application->getServiceManager()->get('doctrine.entitymanager.orm_default');
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
     $schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata());
     // build audit database
     $auditEntityManager = $application->getServiceManager()->get('doctrine.entitymanager.orm_zf_doctrine_audit');
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($auditEntityManager);
     $schemaTool->createSchema($auditEntityManager->getMetadataFactory()->getAllMetadata());
     // Run audit fixtures
     $loader = new ServiceLocatorAwareLoader($application->getServiceManager());
     $purger = new ORMPurger();
     $executor = new ORMExecutor($auditEntityManager, $purger);
     $loader->loadFromDirectory(__DIR__ . '/../src/Fixture');
     $executor->execute($loader->getFixtures(), true);
 }
开发者ID:api-skeletons,项目名称:zf-doctrine-audit,代码行数:17,代码来源:Bootstrap.php

示例8: createHelpers

 /**
  *
  */
 private function createHelpers()
 {
     /** @var HelperPluginManager $viewPluginManager */
     $viewPluginManager = $this->application->getServiceManager()->get('view-helper-manager');
     foreach ($viewPluginManager->getCanonicalNames() as $name) {
         $helper = $viewPluginManager->get($name);
         $this->viewHelpers[$name] = get_class($helper);
     }
 }
开发者ID:geeh,项目名称:snubbed,代码行数:12,代码来源:ViewSnubber.php

示例9: testInitCurrentLocaleWithLangOnQuery

 public function testInitCurrentLocaleWithLangOnQuery()
 {
     $expected = 'es_ES';
     $e = $this->createMvcEvent($expected);
     $this->assertEquals('id_ID', $this->app->getServiceManager()->get('translator')->getLocale());
     $this->module->initCurrentLocale($e);
     // Test that current locale has changed to the one in the query
     $this->assertEquals($expected, $this->app->getServiceManager()->get('translator')->getLocale());
 }
开发者ID:jkhaled,项目名称:LearnZF2,代码行数:9,代码来源:ModuleTest.php

示例10: it_aborts_bootstrap_on_console

 public function it_aborts_bootstrap_on_console(MvcEvent $event, Application $application, ServiceLocatorInterface $serviceLocator, AccessListener $listener, EventManager $eventManager)
 {
     Console::overrideIsConsole(true);
     $application->getEventManager()->willReturn($eventManager);
     $serviceLocator->get(AccessListener::class)->willReturn($listener);
     $application->getServiceManager()->willReturn($serviceLocator);
     $event->getApplication()->willReturn($application);
     $listener->attach($eventManager)->shouldNotBeCalled();
     $this->onBootstrap($event);
 }
开发者ID:saeven,项目名称:zf3-circlical-user,代码行数:10,代码来源:ModuleSpec.php

示例11: getApplication

 /**
  * Get the application object
  * @return \Zend\Mvc\Application
  */
 public static function getApplication()
 {
     if (self::$application instanceof \Zend\Mvc\ApplicationInterface) {
         return self::$application;
     }
     self::$application = \Zend\Mvc\Application::init(self::getApplicationConfig());
     $oEventManager = self::$application->getEventManager();
     $oEventManager->detach(self::$application->getServiceManager()->get('SendResponseListener'));
     return self::$application;
 }
开发者ID:zf2-boiler-app,项目名称:app-test,代码行数:14,代码来源:AbstractBootstrap.php

示例12: generateControllerSnub

    /**
     * @param string $abstractController
     */
    public function generateControllerSnub($abstractController)
    {
        /** @var \Zend\Mvc\Controller\PluginManager $controllerPluginManager */
        $controllerPluginManager = $this->application->getServiceManager()->get('controller-plugin-manager');
        $methods = [];
        foreach ($controllerPluginManager->getCanonicalNames() as $key => $name) {
            $pluginClass = $controllerPluginManager->get($name);
            $methods[$key] = get_class($pluginClass);
        }
        $className = str_replace('\\', '', $abstractController);
        $generated = date("Y-m-d H:i:s");
        $snub = <<<SNUB
<?php

/**
 * Generated on {$generated}
 */
namespace Snub;

/**

SNUB;
        foreach ($methods as $name => $returns) {
            if (strpos($returns, '\\') !== 0) {
                $returns = '\\' . $returns;
            }
            $snub .= " * @method {$returns} {$name}()" . PHP_EOL;
        }
        $snub .= <<<SNUB
 * @method \\Zend\\Http\\PhpEnvironment\\Request getRequest()
 * @property \\Zend\\Http\\PhpEnvironment\\Request request
 * @method \\Zend\\Http\\PhpEnvironment\\Response getResponse()
 * @property \\Zend\\Http\\PhpEnvironment\\Response response
 */
abstract class Snubbed{$className} extends {$abstractController} {}


SNUB;
        $this->fileWriter->write('.ide/Snub/Snubbed' . $className . '.php', $snub);
    }
开发者ID:geeh,项目名称:snubbed,代码行数:43,代码来源:ControllerSnubber.php

示例13: getServiceManager

 public static function getServiceManager()
 {
     return self::$applicationInstance->getServiceManager();
 }
开发者ID:argentinaluiz,项目名称:js_zf2_library,代码行数:4,代码来源:JSZendFunctionsStaticTrait.php

示例14: getModules

 /**
  * @return array
  */
 public function getModules()
 {
     /** @var $moduleManager \Zend\ModuleManager\ModuleManager */
     $moduleManager = $this->application->getServiceManager()->get('ModuleManager');
     return $moduleManager->getLoadedModules();
 }
开发者ID:enlitepro,项目名称:enlite-behat-extension,代码行数:9,代码来源:ModuleManager.php

示例15: getDataMapperManager

 /**
  * @return DataMapperManager
  */
 public function getDataMapperManager()
 {
     return $this->application->getServiceManager()->get(DataMapperManager::class);
 }
开发者ID:stefanotorresi,项目名称:thorr-oauth2-doctrine,代码行数:7,代码来源:IntegrationTestCase.php


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