/** * @param \Nette\DI\Container * @param \Symfony\Component\Console\Helper\HelperSet * @return \Symfony\Component\Console\Application */ public static function createConsole(\Nette\DI\Container $container, \Symfony\Component\Console\Helper\HelperSet $helperSet = NULL) { $console = new \Symfony\Component\Console\Application(Framework::NAME . " Command Line Interface", Framework::VERSION); if (!$helperSet) { $helperSet = new \Symfony\Component\Console\Helper\HelperSet(); $helperSet->set(new \Doctrine\ODM\MongoDB\Tools\Console\Helper\DocumentManagerHelper($container->documentManager), 'dm'); $helperSet->set(new \Symfony\Component\Console\Helper\DialogHelper(), 'dialog'); } $console->setHelperSet($helperSet); $console->setCatchExceptions(FALSE); $commands = array(); foreach (array_keys($container->findByTag('consoleCommand')) as $name) { $commands[] = $container->getService($name); } $console->addCommands($commands); return $console; }
<?php /* * This file is part of prooph/proophessor. * (c) 2014-2015 prooph software GmbH <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * Date: 9/5/15 - 10:10 PM */ /** * This makes our life easier when dealing with paths. Everything is relative * to the application root now. */ chdir(dirname(__DIR__)); // Setup autoloading require 'vendor/autoload.php'; $container = (require 'config/container.php'); $cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', \Doctrine\DBAL\Migrations\MigrationsVersion::VERSION()); $helperSet = new \Symfony\Component\Console\Helper\HelperSet(); $helperSet->set(new \Symfony\Component\Console\Helper\DialogHelper(), 'dialog'); $helperSet->set(new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($container->get('doctrine.connection.default')), 'connection'); $cli->setCatchExceptions(true); $cli->setHelperSet($helperSet); $cli->addCommands(array(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())); $cli->run();
$config = (include $appRoot . '/resources/map-config.php'); $loader = new ResourceLoader(); $serverZonesFile = $loader->getFilePath('server.json'); $worldZonesFile = $loader->getFilePath('world.json'); $labelsFile = $loader->getFilePath('labels.json'); //$db = new SQLite3(__DIR__ . '/../app/maptiles.sqlite3'); //if (!$db->querySingle('SELECT 1 FROM sqlite_master WHERE type = "table" and name = "map"')) { // $sql = file_get_contents(__DIR__ . '/../app/maptiles-schema.sql'); // if (!$db->exec($sql)) { // $err = $db->lastErrorMsg(); // throw new \RuntimeException("Failed to create maptiles.sqlite3 database ({$err})"); // } //} //$tilestorage = new \Bmsite\Maps\TileStorage($db); $tilestorage = new \Bmsite\Maps\Tiles\FileTileStorage($appRoot . '/tiles'); $resources = new ResourceHelper(); $resources->set('app.path', $appRoot); $resources->set('map-config', $config); $resources->set('server.json.array', $loader->loadJson('server.json'), true); $resources->set('world.json.array', $loader->loadJson('world.json'), true); $resources->set('labels.json.array', $loader->loadJson('labels.json'), true); $resources->set('tilestorage', $tilestorage); $helperSet = new \Symfony\Component\Console\Helper\HelperSet(); $helperSet->set($resources); $helperSet->set(new \Bmsite\Maps\Tools\Console\Helper\TranslateHelper()); $helperSet->set(new \Bmsite\Maps\Tools\Console\Helper\RegionsHelper()); $cli = new \Symfony\Component\Console\Application('Bmsite Ryzom Map Tiles', '0.1'); $cli->setCatchExceptions(true); $cli->setHelperSet($helperSet); $cli->addCommands(array(new \Bmsite\Maps\Tools\Console\Command\BuildMapTiles())); $cli->run();
/** * @return Symfony\Component\Console\Helper\HelperSet */ public function createServiceConsole__helperSet() { $service = new Symfony\Component\Console\Helper\HelperSet(); $service->set(new Symfony\Component\Console\Helper\ProcessHelper()); $service->set(new Symfony\Component\Console\Helper\DescriptorHelper()); $service->set(new Symfony\Component\Console\Helper\FormatterHelper()); $service->set(new Symfony\Component\Console\Helper\QuestionHelper()); $service->set(new Symfony\Component\Console\Helper\DebugFormatterHelper()); $service->set(new Kdyby\Console\Helpers\PresenterHelper($this->getService('application.application'))); $service->set(new Symfony\Component\Console\Helper\ProgressHelper(FALSE)); $service->set(new Symfony\Component\Console\Helper\DialogHelper(FALSE)); $service->set(new Kdyby\Console\ContainerHelper($this), 'dic'); $service->set($this->getService('doctrine.helper.entityManager'), 'em'); $service->set($this->getService('doctrine.helper.connection'), 'db'); return $service; }
/** * @param \Nette\DI\Container * @return \Symfony\Component\Console\Helper\HelperSet */ public static function createServiceConsoleHelpers(Container $container) { $helperSet = new \Symfony\Component\Console\Helper\HelperSet; $helperSet->set(new DI\ContainerHelper($container), 'container'); $helperSet->set(new Doctrine\EntityManagerHelper($container->doctrineContainer), 'em'); $helperSet->set(new Doctrine\MigrationConfigurationHelper($container->doctrineContainer), 'mc'); $helperSet->set(new \Symfony\Component\Console\Helper\DialogHelper(), 'dialog'); return $helperSet; }
<?php /* * This file is part of prooph/proophessor. * (c) 2014-2015 prooph software GmbH <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * Date: 9/5/15 - 10:10 PM */ /** * This makes our life easier when dealing with paths. Everything is relative * to the application root now. */ chdir(dirname(__DIR__)); // Setup autoloading require 'vendor/autoload.php'; $container = (require 'config/container.php'); /** @var \Doctrine\ORM\EntityManager $em */ $em = $container->get('doctrine.entitymanager.orm_default'); $cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', \Doctrine\DBAL\Migrations\MigrationsVersion::VERSION()); $helperSet = new \Symfony\Component\Console\Helper\HelperSet(); $helperSet->set(new \Symfony\Component\Console\Helper\DialogHelper(), 'dialog'); $helperSet->set(new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em), 'em'); $helperSet->set(new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'connection'); $cli->setCatchExceptions(true); $cli->setHelperSet($helperSet); $cli->addCommands(array(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(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand())); $cli->run();
foreach ($argv as $pos => $arg) { if (strpos($arg, '--database-group') !== FALSE) { $parts = explode('=', $arg); $database_group = $parts[1]; unset($argv2[$pos]); } } $input = new Doctrine_ReadWriteArgvInput($argv2); if (!$input->hasOption('configuration')) { $input->setOption('configuration', Kohana::$config->load('doctrine')->get('configuration')); } // end: hack to get --database-group and pass it to the Doctrine_ORM constructor // create a Doctrine_ORM for one database group $doctrine_orm = new Doctrine_ORM($database_group); // add console helpers $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($doctrine_orm->getEntityManager()->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($doctrine_orm->getEntityManager()))); // create and run Symfony Console application $cli = new Symfony\Component\Console\Application('Kohana Doctrine Command Line Interface</info>' . PHP_EOL . '<comment>use --database-group to specifify another group from database.php (defaut: default)</comment>' . PHP_EOL . '<info>Doctrine', \Doctrine\ORM\Version::VERSION); $cli->setCatchExceptions(true); // Register All Doctrine Commands \Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($cli); // Adding own helpers foreach (Kohana::$config->load('doctrine')->get('console_helpers', array()) as $alias => $helper) { $helperSet->set($helper); } // Set helperSet $cli->setHelperSet($helperSet); // Run with helperset and add own commands \Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet, Kohana::$config->load('doctrine')->get('console_commands', array())); /** * init from configured paths