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


PHP Application::getKernel方法代码示例

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


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

示例1: initDB

 /**
  * create test db.
  */
 public function initDB()
 {
     static::bootKernel();
     $this->application = new Application(static::$kernel);
     $this->em = $this->getEntityManager();
     // drop the database
     $command = new DropDatabaseDoctrineCommand();
     $this->application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:database:drop', '--force' => true));
     $command->run($input, new NullOutput());
     // we have to close the connection after dropping the database so we don't get "No database selected" error
     $connection = $this->application->getKernel()->getContainer()->get('doctrine')->getConnection();
     if ($connection->isConnected()) {
         $connection->close();
     }
     // create the database
     $command = new CreateDatabaseDoctrineCommand();
     $this->application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:database:create'));
     $command->run($input, new NullOutput());
     // create schema
     $command = new CreateSchemaDoctrineCommand();
     $this->application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:schema:create'));
     $command->run($input, new NullOutput());
 }
开发者ID:extdevelopment,项目名称:login-task,代码行数:29,代码来源:TestHelperTrait.php

示例2: setUp

 protected function setUp()
 {
     self::bootKernel();
     $this->application = new Application(self::$kernel);
     // Register doctrine bundles
     $this->application->add(new LoadDataFixturesCommand($this->application->getKernel()->getContainer()->get('doctrine'), $this->application->getKernel()->getContainer()->get('hautelook_alice.fixtures.loader'), $this->application->getKernel()->getContainer()->get('hautelook_alice.doctrine.finder')));
     $this->doctrineManager = $this->application->getKernel()->getContainer()->get('doctrine')->getManager();
     $this->application->setAutoExit(false);
     $this->runConsole("doctrine:schema:drop", ["--force" => true]);
     $this->runConsole("doctrine:schema:create");
 }
开发者ID:Vowow,项目名称:AliceBundle,代码行数:11,代码来源:DoctrineFixtureTest.php

示例3: addConsoleHelpers

 private function addConsoleHelpers(FrameworkApplication $app)
 {
     if (!Util::hasQuestionHelper()) {
         $helper = $app->getKernel()->getContainer()->get('rj_frontend.console.helper.question_legacy');
         $app->getHelperSet()->set($helper, 'question');
     }
 }
开发者ID:regularjack,项目名称:frontend-bundle,代码行数:7,代码来源:RjFrontendBundle.php

示例4: getLogfileContents

 /**
  * Wrapper function to get whole contents of a particular log file as a string
  *
  * @param $name
  *
  * @return string
  * @throws Exception is the logfile does not exist
  */
 protected function getLogfileContents($name)
 {
     if (!$this->doesLogfileExist($name)) {
         throw new \Exception('Could not file logfile with name \'' . $name . '\' to read contents from for test');
     }
     return file_get_contents($this->application->getKernel()->getLogDir() . DIRECTORY_SEPARATOR . $name);
 }
开发者ID:sarelvdwalt,项目名称:BaseCommandBundle,代码行数:15,代码来源:AbstractContainerTest.php

示例5: setApplicationDocumentManager

 /**
  * @param Symfony\Bundle\FrameworkBundle\Console\Application
  * @param string $dmName
  */
 public static function setApplicationDocumentManager(Application $application, $dmName)
 {
     /** @var $dm \Doctrine\ODM\DocumentManager */
     $alias = sprintf("doctrine_mongodb.odm.%s", $dmName);
     $dm = $application->getKernel()->getContainer()->get($alias);
     $helperSet = $application->getHelperSet();
     $helperSet->set(new DocumentManagerHelper($dm), 'dm');
 }
开发者ID:gepo,项目名称:mongodb-migrations-bundle,代码行数:12,代码来源:AntiMattrCommand.php

示例6: setApplicationDocumentManager

 /**
  * Set the document manager on the application.
  *
  * @param Application $application
  * @param string      $dmName
  */
 public static function setApplicationDocumentManager(Application $application, $dmName)
 {
     /** @var $registry ManagerRegistry */
     $registry = $application->getKernel()->getContainer()->get('doctrine_phpcr');
     $documentManager = $registry->getManager($dmName);
     $helperSet = $application->getHelperSet();
     $helperSet->set(new DocumentManagerHelper(null, $documentManager));
 }
开发者ID:xabbuh,项目名称:DoctrinePHPCRBundle,代码行数:14,代码来源:DoctrineCommandHelper.php

示例7: setApplicationHelper

 public static function setApplicationHelper(Application $application, InputInterface $input)
 {
     $doctrine = $application->getKernel()->getContainer()->get('doctrine');
     if ($doctrine->getManagerNames()) {
         self::setApplicationConnection($application, $input->getOption('db'));
     } else {
         self::setApplicationEntityManager($application, $input->getOption('em'));
     }
 }
开发者ID:pavsuri,项目名称:PARMT,代码行数:9,代码来源:DoctrineCommandHelper.php

示例8: configureMigrationsForBundle

 public static function configureMigrationsForBundle(Application $application, $bundle, Configuration $configuration)
 {
     $bundle = $application->getKernel()->getBundle($bundle);
     $dir = $bundle->getPath() . '/DoctrineMigrations';
     $configuration->setMigrationsNamespace($bundle->getNamespace() . '\\DoctrineMigrations');
     $configuration->setMigrationsDirectory($dir);
     $configuration->registerMigrationsFromDirectory($dir);
     $configuration->setName($bundle->getName() . ' Migrations');
     $configuration->setMigrationsTableName(Inflector::tableize($bundle->getName()) . '_migration_versions');
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:10,代码来源:DoctrineCommand.php

示例9: testRunImportCommand

 public function testRunImportCommand()
 {
     $application = new Application($this->getClient()->getKernel());
     $application->add(new ImportCommand());
     $command = $application->find('wallabag:import');
     $tester = new CommandTester($command);
     $tester->execute(['command' => $command->getName(), 'userId' => 1, 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir') . '/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', '--importer' => 'v2']);
     $this->assertContains('imported', $tester->getDisplay());
     $this->assertContains('already saved', $tester->getDisplay());
 }
开发者ID:wallabag,项目名称:wallabag,代码行数:10,代码来源:ImportCommandTest.php

示例10: resolveBundles

 /**
  * Looks at all the bundles registered in the application to return the bundles requested. An exception is thrown
  * if a bundle has not been found.
  *
  * @param Application $application Application in which bundles will be looked in.
  * @param string[]    $names       Bundle names.
  *
  * @return BundleInterface[] Bundles requested.
  * @throws \RuntimeException A bundle could not be resolved.
  */
 public function resolveBundles(Application $application, array $names)
 {
     $bundles = $application->getKernel()->getBundles();
     $result = [];
     foreach ($names as $name) {
         if (false === isset($bundles[$name])) {
             throw new \RuntimeException(sprintf('The bundle "%s" was not found. Bundles availables are: %s.', $name, implode('", "', array_keys($bundles))));
         }
         $result[$name] = $bundles[$name];
     }
     return $result;
 }
开发者ID:Vowow,项目名称:AliceBundle,代码行数:22,代码来源:Finder.php

示例11: setApplicationDocumentManager

 public static function setApplicationDocumentManager(Application $application, $dmName)
 {
     $container = $application->getKernel()->getContainer();
     $dmName = $dmName ? $dmName : 'default';
     $dmServiceName = sprintf('doctrine.odm.mongodb.%s_document_manager', $dmName);
     if (!$container->has($dmServiceName)) {
         throw new \InvalidArgumentException(sprintf('Could not find Doctrine ODM DocumentManager named "%s"', $dmName));
     }
     $dm = $container->get($dmServiceName);
     $helperSet = $application->getHelperSet();
     $helperSet->set(new DocumentManagerHelper($dm), 'dm');
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:12,代码来源:DoctrineODMCommand.php

示例12: setApplicationXmlEntityManager

 public static function setApplicationXmlEntityManager(Application $application, $xemName)
 {
     $container = $application->getKernel()->getContainer();
     $xemName = $xemName ? $xemName : 'default';
     $xemServiceName = sprintf('doctrine.oxm.%s_xml_entity_manager', $xemName);
     if (!$container->has($xemServiceName)) {
         throw new \InvalidArgumentException(sprintf('Could not find Doctrine OXM XmlEntityManager named "%s"', $xemName));
     }
     $xem = $container->get($xemServiceName);
     $helperSet = $application->getHelperSet();
     $helperSet->set(new XmlEntityManagerHelper($xem), 'xem');
 }
开发者ID:pkdevbox,项目名称:DoctrineOXMBundle,代码行数:12,代码来源:DoctrineOXMCommand.php

示例13: setApplicationConnection

 public static function setApplicationConnection(Application $application, $connName)
 {
     $container = $application->getKernel()->getContainer();
     $connName = $connName ? $connName : $container->getParameter('doctrine.dbal.default_connection');
     $connServiceName = sprintf('doctrine.dbal.%s_connection', $connName);
     if (!$container->has($connServiceName)) {
         throw new \InvalidArgumentException(sprintf('Could not find Doctrine Connection named "%s"', $connName));
     }
     $connection = $container->get($connServiceName);
     $helperSet = $application->getHelperSet();
     $helperSet->set(new ConnectionHelper($connection), 'db');
 }
开发者ID:norwayapp,项目名称:Invest,代码行数:12,代码来源:DoctrineCommand.php

示例14: configureMigrationsForBundle

 public static function configureMigrationsForBundle(Application $application, $bundle, Configuration $configuration)
 {
     $configuration->setMigrationsNamespace($bundle . '\\DoctrineMigrations');
     $dirs = $application->getKernel()->getBundleDirs();
     $tmp = str_replace('\\', '/', $bundle);
     $namespace = str_replace('/', '\\', dirname($tmp));
     $bundle = basename($tmp);
     $dir = $dirs[$namespace] . '/' . $bundle . '/DoctrineMigrations';
     $configuration->setMigrationsDirectory($dir);
     $configuration->registerMigrationsFromDirectory($dir);
     $configuration->setName($bundle . ' Migrations');
     $configuration->setMigrationsTableName(Inflector::tableize($bundle) . '_migration_versions');
 }
开发者ID:bill97420,项目名称:symfony,代码行数:13,代码来源:DoctrineCommand.php

示例15: testRunRedisWorkerCommand

 public function testRunRedisWorkerCommand()
 {
     $application = new Application($this->getClient()->getKernel());
     $application->add(new RedisWorkerCommand());
     $factory = new RedisMockFactory();
     $redisMock = $factory->getAdapter('Predis\\Client', true);
     $application->getKernel()->getContainer()->set('wallabag_core.redis.client', $redisMock);
     // put a fake message in the queue so the worker will stop after reading that message
     // instead of waiting for others
     $redisMock->lpush('wallabag.import.readability', '{}');
     $command = $application->find('wallabag:import:redis-worker');
     $tester = new CommandTester($command);
     $tester->execute(['command' => $command->getName(), 'serviceName' => 'readability', '--maxIterations' => 1]);
     $this->assertContains('Worker started at', $tester->getDisplay());
     $this->assertContains('Waiting for message', $tester->getDisplay());
 }
开发者ID:wallabag,项目名称:wallabag,代码行数:16,代码来源:RedisWorkerCommandTest.php


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