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


PHP Mvc\Application类代码示例

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


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

示例1: setup

 public function setup()
 {
     parent::setup();
     $config = (include 'config/application.config.php');
     $config['module_listener_options']['config_static_paths'] = array(getcwd() . '/config/test.config.php');
     if (file_exists(__DIR__ . '/config/test.config.php')) {
         $moduleConfig = (include __DIR__ . '/config/test.config.php');
         array_unshift($config['module_listener_options']['config_static_paths'], $moduleConfig);
     }
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(isset($config['service_manager']) ? $config['service_manager'] : array()));
     $this->serviceManager->setService('ApplicationConfig', $config);
     $this->serviceManager->setFactory('ServiceListener', 'Zend\\Mvc\\Service\\ServiceListenerFactory');
     $moduleManager = $this->serviceManager->get('ModuleManager');
     $moduleManager->loadModules();
     $this->routes = array();
     foreach ($moduleManager->getModules() as $m) {
         $moduleConfig = (include __DIR__ . '/../../../../' . ucfirst($m) . '/config/module.config.php');
         if (isset($moduleConfig['router'])) {
             foreach ($moduleConfig['router']['routes'] as $key => $name) {
                 $this->routes[$key] = $name;
             }
         }
     }
     $this->serviceManager->setAllowOverride(true);
     $this->application = $this->serviceManager->get('Application');
     $this->event = new MvcEvent();
     $this->event->setTarget($this->application);
     $this->event->setApplication($this->application)->setRequest($this->application->getRequest())->setResponse($this->application->getResponse())->setRouter($this->serviceManager->get('Router'));
     $this->createDatabase();
 }
开发者ID:alfredocoj,项目名称:blogzf2tutorial,代码行数:30,代码来源:TestCase.php

示例2: getApplication

 protected function getApplication()
 {
     if (null === $this->application) {
         $this->application = $this->getServiceManager()->get('Application');
         $this->application->bootstrap();
     }
     return $this->application;
 }
开发者ID:outeredge,项目名称:edge-zf2,代码行数:8,代码来源:AbstractTestCase.php

示例3: 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

示例4: setUp

 public function setUp()
 {
     $this->application = $this->getMock('Zend\\Mvc\\Application', array(), array(), '', false);
     $this->event = $this->getMock('Zend\\Mvc\\MvcEvent');
     $this->serviceManager = $this->getMock('Zend\\ServiceManager\\ServiceManager');
     $this->cli = $this->getMock('Symfony\\Component\\Console\\Application', array('run'));
     $this->serviceManager->expects($this->any())->method('get')->with('doctrine.cli')->will($this->returnValue($this->cli));
     $this->application->expects($this->any())->method('getServiceManager')->will($this->returnValue($this->serviceManager));
     $this->event->expects($this->any())->method('getTarget')->will($this->returnValue($this->application));
 }
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:10,代码来源:ModuleTest.php

示例5: setUp

 public function setUp()
 {
     $config = ['modules' => ['Zff\\Html2Pdf'], 'module_listener_options' => []];
     $serviceManager = new ServiceManager((new ServiceManagerConfig())->toArray());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     $application = new Application($config, $serviceManager);
     $application->bootstrap();
     $this->serviceManager = $serviceManager;
 }
开发者ID:wizzvet,项目名称:ZffHtml2pdf,代码行数:10,代码来源:ViewHtml2PdfStrategyFactoryTest.php

示例6: __construct

 public function __construct(HelperPluginManager $pluginManager)
 {
     $this->pluginManager = $pluginManager;
     $this->serviceManager = $pluginManager->getServiceLocator();
     $this->app = $pluginManager->getServiceLocator()->get('Application');
     $this->request = $this->app->getRequest();
     $this->event = $this->app->getMvcEvent();
     $this->em = $this->serviceManager->get('Doctrine\\ORM\\EntityManager');
     $this->translator = $this->serviceManager->get('translator');
 }
开发者ID:Belcebur,项目名称:BelceburBasic,代码行数:10,代码来源:BTools.php

示例7: 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

示例8: 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

示例9: testOnBootstrap

 public function testOnBootstrap()
 {
     $event = new MvcEvent();
     $application = new Application([], Bootstrap::getServiceManager());
     $em = new EventManager();
     $application->setEventManager($em);
     $event->setApplication($application);
     $isConsole = Console::isConsole();
     Console::overrideIsConsole(false);
     $this->module->onBootstrap($event);
     Console::overrideIsConsole($isConsole);
     $this->assertCount(1, $em->getListeners(MvcEvent::EVENT_DISPATCH));
     $this->assertCount(1, $em->getListeners(MvcEvent::EVENT_RENDER));
 }
开发者ID:hummer2k,项目名称:convarnish,代码行数:14,代码来源:ModuleTest.php

示例10: getApplication

 public static function getApplication()
 {
     self::assertZf();
     self::chdirToAppRoot();
     $configPath = self::findAppConfigPath();
     return Application::init(require $configPath);
 }
开发者ID:brs-software,项目名称:stdlib,代码行数:7,代码来源:ZfHelper.php

示例11: init

 /**
  * @see \Zend\Mvc\Application#init()
  * @param array $configuration
  * @return RealZendApplication
  */
 public static function init($configuration = array())
 {
     Exception\ErrorException::$oldErrorHandler = set_error_handler("\\Netis\\Exception\\ErrorException::errorHandler");
     Environment::setEnv(isset($configuration['env']) ? $configuration['env'] : Environment::ENV_PRODUCTION);
     self::detectLoader($configuration);
     return parent::init($configuration);
 }
开发者ID:athemcms,项目名称:netis,代码行数:12,代码来源:ZendApplication.php

示例12: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Start up application with supplied config...');
     $config = $input->getArgument('applicationConfig');
     $path = stream_resolve_include_path($config);
     if (!is_readable($path)) {
         throw new \InvalidArgumentException("Invalid loader path: {$config}");
     }
     // Init the application once using given config
     // This way the late static binding on the AspectKernel
     // will be on the goaop-zf2-module kernel
     \Zend\Mvc\Application::init(include $path);
     if (!class_exists(AspectKernel::class, false)) {
         $message = "Kernel was not initialized yet. Maybe missing module Go\\ZF2\\GoAopModule in config {$path}";
         throw new \InvalidArgumentException($message);
     }
     $kernel = AspectKernel::getInstance();
     $options = $kernel->getOptions();
     if (empty($options['cacheDir'])) {
         throw new \InvalidArgumentException('Cache warmer require the `cacheDir` options to be configured');
     }
     $enumerator = new Enumerator($options['appDir'], $options['includePaths'], $options['excludePaths']);
     $iterator = $enumerator->enumerate();
     $totalFiles = iterator_count($iterator);
     $output->writeln("Total <info>{$totalFiles}</info> files to process.");
     $iterator->rewind();
     set_error_handler(function ($errno, $errstr, $errfile, $errline) {
         throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
     });
     $index = 0;
     $errors = [];
     foreach ($iterator as $file) {
         if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
             $output->writeln("Processing file <info>{$file->getRealPath()}</info>");
         }
         $isSuccess = null;
         try {
             // This will trigger creation of cache
             file_get_contents(FilterInjectorTransformer::PHP_FILTER_READ . SourceTransformingLoader::FILTER_IDENTIFIER . '/resource=' . $file->getRealPath());
             $isSuccess = true;
         } catch (\Exception $e) {
             $isSuccess = false;
             $errors[$file->getRealPath()] = $e;
         }
         if ($output->getVerbosity() == OutputInterface::VERBOSITY_NORMAL) {
             $output->write($isSuccess ? '.' : '<error>E</error>');
             if (++$index % 50 == 0) {
                 $output->writeln("({$index}/{$totalFiles})");
             }
         }
     }
     restore_error_handler();
     if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
         foreach ($errors as $file => $error) {
             $message = "File {$file} is not processed correctly due to exception: {$error->getMessage()}";
             $output->writeln($message);
         }
     }
     $output->writeln('<info>Done</info>');
 }
开发者ID:goaop,项目名称:goaop-zf2-module,代码行数:63,代码来源:Zf2WarmupCommand.php

示例13: getApplicationCommands

 /**
  * Gets application commands
  *
  * @return array
  */
 protected function getApplicationCommands()
 {
     $setupCommands = [];
     $toolsCommands = [];
     $modulesCommands = [];
     $bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP);
     $params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER);
     $params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
     $bootstrap = Bootstrap::create(BP, $params);
     $objectManager = $bootstrap->getObjectManager();
     if (class_exists('Magento\\Setup\\Console\\CommandList')) {
         $serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')->getServiceManager();
         $setupCommandList = new \Magento\Setup\Console\CommandList($serviceManager);
         $setupCommands = $setupCommandList->getCommands();
     }
     if (class_exists('Magento\\Tools\\Console\\CommandList')) {
         $toolsCommandList = new \Magento\Tools\Console\CommandList();
         $toolsCommands = $toolsCommandList->getCommands();
     }
     if ($objectManager->get('Magento\\Framework\\App\\DeploymentConfig')->isAvailable()) {
         $commandList = $objectManager->create('Magento\\Framework\\Console\\CommandList');
         $modulesCommands = $commandList->getCommands();
     }
     $commandsList = array_merge($setupCommands, $toolsCommands, $modulesCommands);
     return $commandsList;
 }
开发者ID:nja78,项目名称:magento2,代码行数:31,代码来源:Cli.php

示例14: __construct

 /**
  * @param string $name  application name
  * @param string $version application version
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
 {
     $this->serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')->getServiceManager();
     $generationDirectoryAccess = new GenerationDirectoryAccess($this->serviceManager);
     if (!$generationDirectoryAccess->check()) {
         $output = new ConsoleOutput();
         $output->writeln('<error>Command line user does not have read and write permissions on var/generation directory.  Please' . ' address this issue before using Magento command line.</error>');
         exit(0);
     }
     /**
      * Temporary workaround until the compiler is able to clear the generation directory
      * @todo remove after MAGETWO-44493 resolved
      */
     if (class_exists(CompilerPreparation::class)) {
         $compilerPreparation = new CompilerPreparation($this->serviceManager, new ArgvInput(), new File());
         $compilerPreparation->handleCompilerEnvironment();
     }
     if ($version == 'UNKNOWN') {
         $directoryList = new DirectoryList(BP);
         $composerJsonFinder = new ComposerJsonFinder($directoryList);
         $productMetadata = new ProductMetadata($composerJsonFinder);
         $version = $productMetadata->getVersion();
     }
     parent::__construct($name, $version);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:30,代码来源:Cli.php

示例15: __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


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