本文整理汇总了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();
}
示例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());
}
}
示例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();
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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());
}
示例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);
}
示例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;
}
示例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);
}
示例13: getServiceManager
public static function getServiceManager()
{
return self::$applicationInstance->getServiceManager();
}
示例14: getModules
/**
* @return array
*/
public function getModules()
{
/** @var $moduleManager \Zend\ModuleManager\ModuleManager */
$moduleManager = $this->application->getServiceManager()->get('ModuleManager');
return $moduleManager->getLoadedModules();
}
示例15: getDataMapperManager
/**
* @return DataMapperManager
*/
public function getDataMapperManager()
{
return $this->application->getServiceManager()->get(DataMapperManager::class);
}