Пример #1
0
 public function setUp()
 {
     $conn = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'user' => 'root', 'password' => '', 'memory' => true));
     $this->data = new \ebussola\job\jobdata\Doctrine($conn, $this->table_name);
     $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($conn)));
     $cli = new \Symfony\Component\Console\Application();
     $cli->setHelperSet($helperSet);
     $cli->addCommands(array(new \ebussola\job\console\InitCommand()));
     $cmd_tester = new \Symfony\Component\Console\Tester\CommandTester($cli->find('jobschedule:init'));
     $cmd_tester->execute(array('command' => 'jobschedule:init', 'table_name' => $this->table_name));
     //Insert some data
     $conn->insert($this->table_name, array('id' => 1, 'expires_on' => strtotime('+1 hour'), 'runner_class' => 'ebussola\\job\\runner', 'schedule' => '@daily', 'command' => 'foo'));
     $conn->insert($this->table_name, array('id' => 2, 'expires_on' => strtotime('+1 hour'), 'runner_class' => 'ebussola\\job\\runner', 'schedule' => '@daily', 'command' => 'bar'));
 }
 /**
  * @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;
 }
Пример #3
0
<?php

chdir('..');
require_once 'Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine');
$classLoader->register();
//$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';
$configFile = 'bin/cli-config.php';
$helperSet = null;
if (file_exists($configFile)) {
    if (!is_readable($configFile)) {
        trigger_error('Configuration file [' . $configFile . '] does not have read permission.', E_ERROR);
    }
    require $configFile;
    foreach ($GLOBALS as $helperSetCandidate) {
        if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) {
            $helperSet = $helperSetCandidate;
            break;
        }
    }
}
$helperSet = $helperSet ?: new \Symfony\Component\Console\Helper\HelperSet();
$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\ORM\Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
$cli->addCommands(array(new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(), new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand()));
$cli->run();
Пример #4
0
<?php

$em = (require_once __DIR__ . '/bootstrap.php');
$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet(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))));
$cli->addCommands(array(new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(), new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand()));
$cli->run();
Пример #5
0
<?php

define('APPLICATION_ENV', 'cli');
require_once __DIR__ . '/../application.php';
$application->bootstrap();
// Retrieve Doctrine Entity Manager
$em = Zend_Registry::get('container')->getService('em');
// Console
$cli = new \Symfony\Component\Console\Application('Newscoop Command Line Interface', \Newscoop\Version::VERSION);
try {
    // Bootstrapping Console HelperSet
    $helperSet = array();
    if ($em !== null) {
        $helperSet['container'] = new \Newscoop\Tools\Console\Helper\ServiceContainerHelper($application->getBootstrap()->getResource('container'));
    }
} catch (\Exception $e) {
    $cli->renderException($e, new \Symfony\Component\Console\Output\ConsoleOutput());
}
$cli->setCatchExceptions(true);
$cli->setHelperSet(new \Symfony\Component\Console\Helper\HelperSet($helperSet));
$cli->addCommands(array(new \Newscoop\Tools\Console\Command\UpdateIngestCommand(), new \Newscoop\Tools\Console\Command\LogMaintenanceCommand(), new \Newscoop\Tools\Console\Command\SendStatsCommand(), new \Newscoop\Tools\Console\Command\UpdateImageStorageCommand()));
$cli->run();
Пример #6
0
<?php

require __DIR__ . '/cli-config.php';
$app = new \Symfony\Component\Console\Application('Doctrine MongoDB ODM');
if (isset($helperSet)) {
    $app->setHelperSet($helperSet);
}
$app->addCommands(array(new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateDocumentsCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateHydratorsCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateProxiesCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateRepositoriesCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\QueryCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\ClearCache\MetadataCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\CreateCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\DropCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\UpdateCommand()));
$app->run();
Пример #7
0
 public function run($args = array())
 {
     $defaults = array('proxy' => array('auto' => true, 'path' => LITHIUM_APP_PATH . '/resources/tmp/cache/Doctrine/Proxies', 'namespace' => 'Doctrine\\Proxies'), 'useModelDriver' => true, 'mapping' => array('class' => null, 'path' => LITHIUM_APP_PATH . '/models'), 'configuration' => null, 'eventManager' => null);
     if ($this->request->params['action'] != 'run') {
         $args = $this->request->argv;
     }
     // Check if we need to add the migration configuration file
     $migrationCommand = false;
     $migrationConfig = true;
     $migration = false;
     $conn = Connections::get($this->connection);
     $conn->_config = $conn->_config + $defaults;
     $i = 0;
     foreach ($args as &$arg) {
         if (strstr($arg, 'migrations:')) {
             $migrationCommand = true;
         }
         if (strstr($arg, 'migrations')) {
             $migration = true;
         }
         if (strstr($arg, '--configuration=')) {
             $migrationConfig = false;
         }
         if (strstr($arg, '--connection')) {
             unset($args[$i]);
         }
         $i++;
     }
     if ($migrationCommand && $migrationConfig) {
         $args[] = '--configuration=' . LITHIUM_APP_PATH . '/config/migrations.yml';
     }
     $input = new \Symfony\Component\Console\Input\ArgvInput($args);
     if (!$conn || !$conn instanceof \app\extensions\data\source\Doctrine) {
         $error = "Error: Could not get Doctrine proxy object from Connections, using";
         $error .= " configuration '{$this->connection}'. Please add the connection or choose";
         $error .= " an alternate configuration using the `--connection` flag.";
         $this->error($error);
         return;
     }
     /*
      * New Doctrine ORM Configuration
      * TODO: load multiple drivers [Annotations, YAML & XML]
      * 
      */
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     //Annotation Driver
     $driver = $config->newDefaultAnnotationDriver(array(LITHIUM_APP_PATH . '/models'));
     $config->setMetadataDriverImpl($driver);
     //Proxy configuration
     $config->setProxyDir($conn->_config['proxy']['path']);
     $config->setProxyNamespace($conn->_config['proxy']['namespace']);
     //EntityManager
     $em = \Doctrine\ORM\EntityManager::create($conn->_config, $config);
     $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), 'dialog' => new \Symfony\Component\Console\Helper\DialogHelper()));
     //CLI
     $cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', \Doctrine\Common\Version::VERSION);
     $cli->setCatchExceptions(true);
     $cli->register('doctrine');
     $cli->setHelperSet($helperSet);
     $cli->addCommands(array(new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(), new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand()));
     // If command called is a doctrine migration command
     if ($migration) {
         $cli->addCommands(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()));
     }
     $cli->run($input);
 }
Пример #8
0
	/**
	 * @param \Nette\DI\Container
	 * @return \Symfony\Component\Console\Application
	 */
	public static function createServiceConsole(Container $container)
	{
		$commands = $container->consoleCommands;
        if ($commands instanceof \Nella\FreezableArray) {
        	$commands->freeze();
			$commands = $commands->iterator->getArrayCopy();
        }

        $cli = new \Symfony\Component\Console\Application(
			Framework::NAME . " Command Line Interface", Framework::VERSION
		);
        $cli->setCatchExceptions(FALSE);
        $cli->setHelperSet($container->consoleHelpers);
		$cli->addCommands($commands);
        return $cli;
	}