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


PHP AppKernel::getBundles方法代码示例

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


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

示例1: getFixtures

 /**
  * Takes a fixture config object and returns a list of fixture files
  *
  * @param FixtureConfig $fixtureConfig
  * @return array
  */
 public function getFixtures($fixtureConfig)
 {
     $fixtures = [];
     // Apply fixture config
     if (null !== $fixtureConfig->getFixtures()) {
         $fixtures = $fixtureConfig->getFixtures();
     }
     // Apply bundle config
     if (null !== $fixtureConfig->getBundles()) {
         $fixtures = array_merge($fixtures, $this->resolveBundles($fixtureConfig->getBundles()));
     }
     if (count($fixtures) == 0) {
         $fixtures = $this->resolveBundles(array_keys($this->kernel->getBundles()));
     }
     return $fixtures;
 }
开发者ID:alsbury,项目名称:malice,代码行数:22,代码来源:FixtureConfigResolver.php

示例2: __construct

 /**
  *
  * @param array $connection
  * @param array $paths Array of Paths where Search Entities are found
  * @param \AppKernel $kernel
  */
 public function __construct(array $connection, array $paths = array(), \AppKernel $kernel)
 {
     $cacheProvider = 'Doctrine\\Common\\Cache\\ArrayCache';
     //Annotation metadata driver
     $config = new Configuration();
     $md = $config->newDefaultAnnotationDriver($paths);
     $config->setMetadataDriverImpl($md);
     $config->setMetadataCacheImpl(new $cacheProvider());
     $config->setEntitySerializer(new CallbackSerializer('toESDocument', 'fromESDocument'));
     $bundles = $kernel->getBundles();
     $entityNamespaces = array();
     foreach ($bundles as $bundle) {
         $nameSpace = $bundle->getNamespace();
         $name = $bundle->getName();
         $entityNamespaces[$name] = $nameSpace;
     }
     $config->setEntityNamespaces($entityNamespaces);
     $client = new \Elastica\Client(array('connections' => array($connection)));
     $this->searchManager = new SearchManager($config, new \Revinate\SearchBundle\Lib\Search\ElasticSearch\Client($client), new EventManager());
     $this->mappingManager = new MappingManager($this->searchManager, $kernel->getEnvironment());
 }
开发者ID:revinate,项目名称:search-bundle,代码行数:27,代码来源:RevinateSearch.php

示例3: requestAction

 public function requestAction()
 {
     $request = $this->get('request');
     if ($request->isXmlHttpRequest() && $request->getMethod() == 'POST') {
         // retrieve command string
         $sf2Command = stripslashes($request->request->get('command'));
         if ($sf2Command == '.') {
             // this trick is used to give the possibility to have "php app/console" equivalent
             $sf2Command = 'list';
         }
         //TODO: not really efficient
         $app = $request->request->get('app') ? $request->request->get('app') : basename($this->get('kernel')->getRootDir());
         if (!in_array($app, $this->container->getParameter('sf2gen_console.apps'))) {
             return new Response('This application is not allowed...', 200);
             // set to 200 to allow console display
         }
         //Try to run a separate shell process
         if ($this->container->getParameter('sf2gen_console.new_process')) {
             //Try to run a separate shell process
             try {
                 $php = $this->getPhpExecutable();
                 $commandLine = $php . ' ' . $app . '/' . 'console ';
                 if (!empty($sf2Command)) {
                     $commandLine .= $sf2Command;
                 }
                 $p = new Process($commandLine, dirname($this->get('kernel')->getRootDir()), null, null, 30, array('suppress_errors' => false, 'bypass_shell' => false));
                 $p->run();
                 $output = $p->getOutput();
                 /*
                 if the process is not successful:
                 - 1) Symfony throws an error and ouput is not empty; continue without Exception.
                 - 2) Process throws an error and ouput is empty => Exception!
                 */
                 if (!$p->isSuccessful() && empty($output)) {
                     throw new \RuntimeException('Unabled to run the process.');
                 }
             } catch (\Exception $e) {
                 // not trying the other method. It is interesting to know where it is not working (single process or not)
                 return new Response(nl2br("The request failed when using a separated shell process. Try to use 'new_process: false' in configuration.\n Error : " . $e->getMessage()));
             }
         } else {
             //Try to execute a console within this process
             //TODO: fix cache:clear issue
             try {
                 //Prepare input
                 $args = preg_split("/ /", trim($sf2Command));
                 array_unshift($args, "fakecommandline");
                 //To simulate the console's arguments
                 $app = $args[1];
                 $input = new ArgvInput($args);
                 //Prepare output
                 ob_start();
                 $output = new StreamOutput(fopen("php://output", 'w'), StreamOutput::VERBOSITY_NORMAL, true, new OutputFormatterHtml(true));
                 //Start a kernel/console and an application
                 $env = $input->getParameterOption(array('--env', '-e'), 'dev');
                 $debug = !$input->hasParameterOption(array('--no-debug', ''));
                 $kernel = new \AppKernel($env, $debug);
                 $kernel->boot();
                 $application = new Application($kernel);
                 foreach ($kernel->getBundles() as $bundle) {
                     $bundle->registerCommands($application);
                 }
                 //integrate all availables commands
                 //Find, initialize and run the real command
                 $run = $application->find($app)->run($input, $output);
                 $output = ob_get_contents();
                 ob_end_clean();
             } catch (\Exception $e) {
                 return new Response(nl2br("The request failed  when using same process.\n Error : " . $e->getMessage()));
             }
         }
         // common response for both methods
         if (empty($output)) {
             $output = 'The command "' . $sf2Command . '" was successful.';
         }
         return new Response($this->convertOuput($output));
     }
     return new Response('This request was not found.', 404);
     // request is not a POST request
 }
开发者ID:nicodmf,项目名称:ConsoleBundle,代码行数:80,代码来源:ConsoleController.php


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