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


PHP Console\ConsoleRunner类代码示例

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


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

示例1: register

 /**
  * {@inheritdoc}
  */
 public function register(Container $c)
 {
     $c['migrations.apps'] = function ($c) {
         $apps = new Container();
         foreach ($c['migrations.options'] as $key => $options) {
             $apps[$key] = function () use($c, $key, $options) {
                 $db = $c['dbs'][$key];
                 return $c['migrations.create_app']($c['migrations.create_helpers']($db), $c['migrations.create_commands']($db, $options));
             };
         }
         return $apps;
     };
     $c['migrations.create_app'] = $c->protect(function ($helpers, $commands) {
         return ConsoleRunner::createApplication($helpers, $commands);
     });
     $c['migrations.create_helpers'] = $c->protect(function ($db) {
         return new HelperSet(['db' => new ConnectionHelper($db), 'dialog' => new QuestionHelper()]);
     });
     $c['migrations.create_commands'] = $c->protect(function ($db, $options) {
         $config = new Configuration($db);
         if (isset($options['namespace'])) {
             $config->setMigrationsNamespace($options['namespace']);
         }
         $config->setMigrationsDirectory($options['path']);
         $config->registerMigrationsFromDirectory($options['path']);
         if (isset($options['table'])) {
             $config->setMigrationsTableName($options['table']);
         }
         $commands = [new DiffCommand(), new ExecuteCommand(), new GenerateCommand(), new MigrateCommand(), new StatusCommand(), new VersionCommand()];
         foreach ($commands as $command) {
             $command->setMigrationConfiguration($config);
         }
         return $commands;
     });
 }
开发者ID:okeyaki,项目名称:silex-doctrine-migrations,代码行数:38,代码来源:DoctrineMigrationsServiceProvider.php

示例2: run

 public function run()
 {
     $entityManager = null;
     if (is_array($_SERVER['argv'])) {
         foreach ($_SERVER['argv'] as $key => $value) {
             if (substr($value, 0, 5) === '--em=') {
                 $entityManager = substr($value, 5);
                 unset($_SERVER['argv'][$key]);
                 if (is_int($_SERVER['argc'])) {
                     $_SERVER['argc']--;
                 }
                 break;
             }
         }
     }
     $commands = $this->container->getDoctrine()->getCommands();
     $helperSet = $this->container->getDoctrine()->getHelperSet($entityManager);
     if (!$helperSet instanceof HelperSet) {
         foreach ($GLOBALS as $helperSetCandidate) {
             if ($helperSetCandidate instanceof HelperSet) {
                 $helperSet = $helperSetCandidate;
                 break;
             }
         }
     }
     ConsoleRunner::run($helperSet, $commands);
 }
开发者ID:sinergi,项目名称:core,代码行数:27,代码来源:DoctrineRuntime.php

示例3: onBootstrap

 /**
  * {@inheritDoc}
  */
 public function onBootstrap(EventInterface $e)
 {
     /* @var $app \Zend\Mvc\ApplicationInterface */
     $app = $e->getTarget();
     $events = $app->getEventManager()->getSharedManager();
     // Attach to helper set event and load the entity manager helper.
     $events->attach('doctrine', 'loadCli.post', function (EventInterface $e) {
         /* @var $cli \Symfony\Component\Console\Application */
         $cli = $e->getTarget();
         ConsoleRunner::addCommands($cli);
         $cli->addCommands(array(new DiffCommand(), new ExecuteCommand(), new GenerateCommand(), new MigrateCommand(), new StatusCommand(), new VersionCommand()));
         /* @var $sm ServiceLocatorInterface */
         $sm = $e->getParam('ServiceManager');
         /* @var $em \Doctrine\ORM\EntityManager */
         $em = $sm->get('doctrine.entitymanager.orm_default');
         $helperSet = $cli->getHelperSet();
         $helperSet->set(new DialogHelper(), 'dialog');
         $helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
         $helperSet->set(new EntityManagerHelper($em), 'em');
     });
     $config = $app->getServiceManager()->get('Config');
     $app->getServiceManager()->get('doctrine.entity_resolver.orm_default');
     if (isset($config['zenddevelopertools']['profiler']['enabled']) && $config['zenddevelopertools']['profiler']['enabled']) {
         $app->getServiceManager()->get('doctrine.sql_logger_collector.orm_default');
     }
 }
开发者ID:ramonjmz,项目名称:cursozf2,代码行数:29,代码来源:Module.php

示例4: __construct

 /**
  * Constructor
  *
  * @param Application $console Console
  * @param ContainerInterface $container Container DI
  */
 public function __construct(Application $console, ContainerInterface $container)
 {
     $entityManager = $container->get('EntityManager');
     $helperSet = ConsoleRunner::createHelperSet($entityManager);
     $helperSet->set(new QuestionHelper(), 'dialog');
     $console->setHelperSet($helperSet);
     ConsoleRunner::addCommands($console);
 }
开发者ID:danielspk,项目名称:tornadohttpskeletonapplication,代码行数:14,代码来源:ORMRegister.php

示例5: registerCommands

 public function registerCommands(Application $application)
 {
     parent::registerCommands($application);
     //include Doctrine ORM commands if exist
     if (class_exists('Doctrine\\ORM\\Version')) {
         ConsoleRunner::addCommands($application);
     }
 }
开发者ID:skillberto,项目名称:ConsoleExtendBundle,代码行数:8,代码来源:SkillbertoConsoleExtendBundle.php

示例6: testCreateApplication

 public function testCreateApplication()
 {
     $helperSet = new HelperSet();
     $app = ConsoleRunner::createApplication($helperSet);
     $this->assertInstanceOf('Symfony\\Component\\Console\\Application', $app);
     $this->assertSame($helperSet, $app->getHelperSet());
     $this->assertEquals(Version::VERSION, $app->getVersion());
 }
开发者ID:selimcr,项目名称:servigases,代码行数:8,代码来源:ConsoleRunnerTest.php

示例7: doRun

 /**
  * {@inheritDoc}
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $this->setHelperSet(ConsoleRunner::createHelperSet($this->app->get('doctrine.orm.entity_manager')));
     $this->getHelperSet()->set(new QuestionHelper());
     $this->getHelperSet()->set(new DialogHelper());
     $this->registerCommands();
     $this->io = new ConsoleIO($input, $output, $this->getHelperSet());
     return parent::doRun($input, $output);
 }
开发者ID:Bonscho,项目名称:packages,代码行数:12,代码来源:Application.php

示例8: route_model

 public function route_model()
 {
     // GET ENTITY MANAGER
     $em = $this->doctrine->getEntityManager();
     // CALL CONSOLE RUNNER
     $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)));
     // GET CONSOLE RUNNER
     return \Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet);
 }
开发者ID:phpcodebooster,项目名称:package,代码行数:9,代码来源:RouterService.php

示例9: __construct

 public function __construct()
 {
     parent::__construct(static::NAME, static::VERSION);
     //Add Doctrine support to console
     $em = Configuration::getEntityManager();
     $doctrineHelperSet = new HelperSet(['db' => new ConnectionHelper($em->getConnection()), 'em' => new EntityManagerHelper($em)]);
     $this->setHelperSet($doctrineHelperSet);
     ConsoleRunner::addCommands($this);
     $this->addCommands([new Command\ModuleUpdateCommand()]);
 }
开发者ID:adamjakab,项目名称:D8ModScan,代码行数:10,代码来源:Application.php

示例10: registerEntityManager

 private function registerEntityManager(Application $app, $serviceName, Connection $connection, Configuration $metadataConfig)
 {
     $app[$serviceName] = $app->share(function () use($app, $connection, $metadataConfig) {
         return EntityManager::create($connection, $metadataConfig);
     });
     // create a console for every manager
     $consoleServiceName = sprintf('%s.console', $serviceName);
     $app[$consoleServiceName] = $app->share(function () use($app, $serviceName) {
         return ConsoleRunner::createApplication(ConsoleRunner::createHelperSet($app[$serviceName]));
     });
 }
开发者ID:everlution,项目名称:silex-doctrine-orm-service,代码行数:11,代码来源:SilexDoctrineOrmServiceProvider.php

示例11: ormCommands

 /**
  * @param $orm
  */
 public function ormCommands($orm)
 {
     if (is_array($orm) && in_array('doctrine', $orm)) {
         /** @var EntityManager $em */
         $em = Model::orm('doctrine')->getOrm();
         $helperSet = ConsoleRunner::createHelperSet($em);
         $this->cli->setCatchExceptions(true);
         $this->cli->setHelperSet($helperSet);
         ConsoleRunner::addCommands($this->cli);
     }
 }
开发者ID:jetfirephp,项目名称:framework,代码行数:14,代码来源:ConsoleProvider.php

示例12: actionIndex

 public function actionIndex()
 {
     /**
      * @var $em \Doctrine\ORM\EntityManager
      */
     $em = ApplicationConsole::app()->db->doctrine;
     $helperSet = new HelperSet(['db' => new ConnectionHelper($em->getConnection()), 'em' => new EntityManagerHelper($em)]);
     //unset($_SERVER['argv'][0]);
     unset($_SERVER['argv'][1]);
     $_SERVER['argv'] = array_values($_SERVER['argv']);
     \Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet);
 }
开发者ID:visionp,项目名称:TestFramework,代码行数:12,代码来源:ControllerDoctrine.php

示例13: _before

 protected function _before()
 {
     $credentials = new DbCredentials();
     $container = ContainerService::getInstance()->setDbCredentials($credentials)->addEntityPath('src/Entity')->getContainer();
     $em = $container['doctrine.entity_manager'];
     $helperSet = ConsoleRunner::createHelperSet($em);
     $helperSet->set(new DialogHelper(), 'dialog');
     $this->app = new Application();
     $gen = new GenerateProxy();
     $gen->setHelperSet($helperSet);
     $this->app->add($gen);
     $this->app->add(new VersionCommand());
 }
开发者ID:delboy1978uk,项目名称:common,代码行数:13,代码来源:GenerateProxiesTest.php

示例14: _before

 protected function _before()
 {
     $credentials = new DbCredentials();
     $container = ContainerService::getInstance()->setDbCredentials($credentials)->addEntityPath('src/Entity')->getContainer();
     $em = $container['doctrine.entity_manager'];
     $helperSet = ConsoleRunner::createHelperSet($em);
     $helperSet->set(new DialogHelper(), 'dialog');
     $configuration = new Configuration($em->getConnection());
     $configuration->setMigrationsNamespace('Migrations');
     $configuration->setMigrationsTableName('Migration');
     $this->app = new Application();
     $mig = new Migration();
     $mig->setMigrationConfiguration($configuration);
     $this->app->add($mig);
     $this->app->add(new VersionCommand());
 }
开发者ID:delboy1978uk,项目名称:common,代码行数:16,代码来源:MigrationTest.php

示例15: setupDoctrineCommands

 public function setupDoctrineCommands()
 {
     if (!Core::make('app')->isInstalled()) {
         return;
     }
     $helperSet = ConsoleRunner::createHelperSet(\ORM::entityManager('core'));
     $this->setHelperSet($helperSet);
     $migrationsConfiguration = new MigrationsConfiguration();
     /** @var \Doctrine\DBAL\Migrations\Tools\Console\Command\AbstractCommand[] $commands */
     $commands = array(new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand());
     foreach ($commands as $migrationsCommand) {
         $migrationsCommand->setMigrationConfiguration($migrationsConfiguration);
         $this->add($migrationsCommand);
     }
     ConsoleRunner::addCommands($this);
 }
开发者ID:kreativmind,项目名称:concrete5-5.7.0,代码行数:16,代码来源:Application.php


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