當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ConsoleRunner::addCommands方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConsoleRunner::addCommands方法的具體用法?PHP ConsoleRunner::addCommands怎麽用?PHP ConsoleRunner::addCommands使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\Tools\Console\ConsoleRunner的用法示例。


在下文中一共展示了ConsoleRunner::addCommands方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

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

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

示例4: run

 /**
  * Run console with the given helperset.  Use the in-built Doctrine commands, plus Flextrine specific ones.
  *
  * @param \Symfony\Component\Console\Helper\HelperSet $helperSet
  * @return void
  */
 public static function run(HelperSet $helperSet)
 {
     $cli = new Application('Doctrine Command Line Interface', \Doctrine\ORM\Version::VERSION);
     $cli->setCatchExceptions(true);
     $cli->setHelperSet($helperSet);
     parent::addCommands($cli);
     self::addCommands($cli);
     $cli->run();
 }
開發者ID:gomestai,項目名稱:flextrine,代碼行數:15,代碼來源:ConsoleRunner.php

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

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

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

示例8: init

 /**
  * {@inheritDoc}
  */
 public function init(ModuleManager $e)
 {
     $events = $e->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();
         /* @var $sm ServiceLocatorInterface */
         $sm = $e->getParam('ServiceManager');
         $em = $sm->get('doctrine.entitymanager.orm_default');
         $paths = $sm->get('doctrine.configuration.fixtures');
         $importCommand = new ImportCommand();
         $importCommand->setEntityManager($em);
         $importCommand->setPath($paths);
         ConsoleRunner::addCommands($cli);
         $cli->addCommands(array($importCommand));
     });
 }
開發者ID:oscar121,項目名稱:doggerout,代碼行數:21,代碼來源:Module.php

示例9: onBootstrap

 public function onBootstrap(EventInterface $e)
 {
     $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) {
         $cli = $e->getTarget();
         ConsoleRunner::addCommands($cli);
         if (class_exists('Doctrine\\DBAL\\Migrations\\Versions')) {
             $cli->add(array(new DiffCommand(), new ExecuteCommand(), new GenerateCommand(), new MigrateCommand(), new StatusCommand(), new VersionCommand()));
         }
         $sm = $e->getParam('ServiceManager');
         $em = $sm->get('doctrine.entitymanager.orm_another');
         $helperSet = $cli->getHelperSet();
         $helperSet->set(new DialogHelper(), 'dialog');
         $helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
         $helperSet->set(new EntityManagerHelper($em), 'em');
     });
 }
開發者ID:89snake89,項目名稱:PHPTest,代碼行數:19,代碼來源:Module.php

示例10: addOrmCommands

 /**
  * Add Doctrine commands
  *
  * @return $this
  */
 public function addOrmCommands()
 {
     ConsoleRunner::addCommands($this);
     return $this;
 }
開發者ID:myovchev,項目名稱:zaralab-api,代碼行數:10,代碼來源:App.php

示例11: SilexApplication

use Symfony\Component\Console\Helper\HelperSet;
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use MJanssen\Command\CacheClearCommand;
use MJanssen\Command\DocsCreateCommand;
use MJanssen\Command\LogClearCommand;
chdir(dirname(__DIR__));
$loader = (require_once 'vendor/autoload.php');
set_time_limit(0);
$app = new SilexApplication();
$cli = true;
require_once 'app/bootstrap.php';
$console = new ConsoleApplication('Silex - Rest API Edition', '1.0');
$console->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', 'dev'));
$command = new CacheClearCommand();
$command->setCachePath($app['cache.path']);
$console->add($command);
$command = new LogClearCommand();
$command->setLogPath($app['log.path']);
$console->add($command);
$command = new DocsCreateCommand();
$command->setApplicationPath($app['app.path']);
$console->add($command);
/*
 * Doctrine CLI
 */
$helperSet = new HelperSet(array('db' => new ConnectionHelper($app['orm.em']->getConnection()), 'em' => new EntityManagerHelper($app['orm.em'])));
$console->setHelperSet($helperSet);
ConsoleRunner::addCommands($console);
$console->run();
開發者ID:roman-pavlyshyn,項目名稱:silex-rest-api,代碼行數:31,代碼來源:console.php

示例12: registerCommands

 /**
  * @param OutputInterface $output
  */
 protected function registerCommands(OutputInterface $output)
 {
     //Wrap database related logic in a try-catch
     //so that non-db commands can still execute
     try {
         $em = $this->kernel->getContainer()->get('models');
         // setup doctrine commands
         $helperSet = $this->getHelperSet();
         $helperSet->set(new EntityManagerHelper($em), 'em');
         $helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
         DoctrineConsoleRunner::addCommands($this);
         $this->registerEventCommands();
     } catch (\Exception $e) {
         $formatter = $this->getHelperSet()->get('formatter');
         $output->writeln($formatter->formatBlock('WARNING! ' . $e->getMessage() . " in " . $e->getFile(), 'error'));
     }
     $this->registerFilesystemCommands();
 }
開發者ID:GerDner,項目名稱:luck-docker,代碼行數:21,代碼來源:Application.php

示例13: HelperSet

        case 'yml':
        case 'yaml':
            //$driver = new YamlDriver( $mappingPaths );
            //$driver->setFileExtension('.yml');
            $ymlConfig = Setup::createYAMLMetadataConfiguration($mappingPaths, $env == 'dev');
            //$ymlConfig->setMetadataDriverImpl( $driver );
            $entityManager = EntityManager::create($dbParams, $ymlConfig);
            break;
        case 'annotation':
            $annotationConfig = Setup::createAnnotationMetadataConfiguration($mappingPaths, $env == 'dev');
            $entityManager = EntityManager::create($dbParams, $annotationConfig);
            break;
        default:
            throw new \Exception("Config: Unknown mapping type of '{$mappingType}'.");
    }
    if (empty($entityManager)) {
        throw new \Exception("Config: Unable to instantiate an entity manager. Please check the configuration.");
    }
    $helperSet = new HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($entityManager->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($entityManager)));
    $app = new DoctrineConsole();
    $app->setCatchExceptions(false);
    $app->setDispatcher($dispatcher);
    $app->setHelperSet($helperSet);
    ConsoleRunner::addCommands($app);
    $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\LatestCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand());
    $app->addCommands($commands);
    $app->run();
} catch (\Exception $e) {
    $output = new \Symfony\Component\Console\Output\ConsoleOutput();
    $app->renderException($e, $output->getErrorOutput());
}
開發者ID:northern,項目名稱:DoctrineConsole,代碼行數:31,代碼來源:doctrine.php

示例14: runConsole

 /**
  * @return RZ\Roadiz\Core\Kernel $this
  */
 public function runConsole()
 {
     /*
      * Define a request wide timezone
      */
     if (!empty($this->container['config']["timezone"])) {
         date_default_timezone_set($this->container['config']["timezone"]);
     } else {
         date_default_timezone_set("Europe/Paris");
     }
     $application = new Application('Roadiz Console Application', static::$cmsVersion);
     $helperSet = new HelperSet(['configuration' => new ConfigurationHelper($this->container['config']), 'db' => new ConnectionHelper($this->container['em']->getConnection()), 'em' => new EntityManagerHelper($this->container['em']), 'question' => new QuestionHelper(), 'solr' => new SolrHelper($this->container['solr']), 'ns-cache' => new CacheProviderHelper($this->container['nodesSourcesUrlCacheProvider']), 'mailer' => new MailerHelper($this->container['mailer']), 'templating' => new TemplatingHelper($this->container['twig.environment']), 'translator' => new TranslatorHelper($this->container['translator'])]);
     $application->setHelperSet($helperSet);
     $application->add(new \RZ\Roadiz\Console\TranslationsCommand());
     $application->add(new \RZ\Roadiz\Console\NodeTypesCommand());
     $application->add(new \RZ\Roadiz\Console\NodesSourcesCommand());
     $application->add(new \RZ\Roadiz\Console\NodesCommand());
     $application->add(new \RZ\Roadiz\Console\ThemesCommand());
     $application->add(new \RZ\Roadiz\Console\InstallCommand());
     $application->add(new \RZ\Roadiz\Console\UsersCommand());
     $application->add(new \RZ\Roadiz\Console\RequirementsCommand());
     $application->add(new \RZ\Roadiz\Console\SolrCommand());
     $application->add(new \RZ\Roadiz\Console\CacheCommand());
     $application->add(new \RZ\Roadiz\Console\ConfigurationCommand());
     $application->add(new \RZ\Roadiz\Console\ThemeInstallCommand());
     $application->add(new \RZ\Roadiz\Console\DocumentDownscaleCommand());
     /*
      * Register user defined Commands
      * Add them in your config.yml
      */
     if (isset($this->container['config']['additionalCommands'])) {
         foreach ($this->container['config']['additionalCommands'] as $commandClass) {
             if (class_exists($commandClass)) {
                 $application->add(new $commandClass());
             } else {
                 throw new \Exception("Command class does not exists (" . $commandClass . ")", 1);
             }
         }
     }
     // Use default Doctrine commands
     ConsoleRunner::addCommands($application);
     $application->run();
     $this->container['stopwatch']->stop('global');
     return $this;
 }
開發者ID:QuangDang212,項目名稱:roadiz,代碼行數:48,代碼來源:Kernel.php

示例15: registerCommands

 protected function registerCommands()
 {
     //Wrap database related logic in a try-catch
     //so that non-db commands can still execute
     try {
         $em = $this->kernel->getContainer()->get('models');
         // setup doctrine commands
         $helperSet = $this->getHelperSet();
         $helperSet->set(new EntityManagerHelper($em), 'em');
         $helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
         DoctrineConsoleRunner::addCommands($this);
         $this->registerEventCommands();
     } catch (\Exception $e) {
     }
     $this->registerFilesystemCommands();
 }
開發者ID:ClaudioThomas,項目名稱:shopware-4,代碼行數:16,代碼來源:Application.php


注:本文中的Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。