示例#1
0
 /**
  * Executes the database initialization and update.
  *
  * @param InputInterface $input Input object
  * @param OutputInterface $output Output object
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $ctx = $this->getContainer()->get('aimeos_context')->get(false, 'command');
     $ctx->setEditor('aimeos:setup');
     $config = $ctx->getConfig();
     $site = $input->getArgument('site');
     $tplsite = $input->getArgument('tplsite');
     $config->set('setup/site', $site);
     $dbconfig = $this->getDbConfig($config);
     $this->setOptions($config, $input);
     $taskPaths = $this->getContainer()->get('aimeos')->get()->getSetupPaths($tplsite);
     $manager = new \Aimeos\MW\Setup\Manager\Multiple($ctx->getDatabaseManager(), $dbconfig, $taskPaths, $ctx);
     $output->writeln(sprintf('Initializing or updating the Aimeos database tables for site <info>%1$s</info>', $site));
     if (($task = $input->getOption('task')) && is_array($task)) {
         $task = reset($task);
     }
     switch ($input->getOption('action')) {
         case 'migrate':
             $manager->migrate($task);
             break;
         case 'rollback':
             $manager->rollback($task);
             break;
         case 'clean':
             $manager->clean($task);
             break;
         default:
             throw new \Exception(sprintf('Invalid setup action "%1$s"', $input->getOption('action')));
     }
 }
示例#2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $ctx = $this->getLaravel()->make('\\Aimeos\\Shop\\Base\\Context')->get(false, 'command');
     $ctx->setEditor('aimeos:setup');
     $config = $ctx->getConfig();
     $site = $this->argument('site');
     $template = $this->argument('tplsite');
     $config->set('setup/site', $site);
     $dbconfig = $this->getDbConfig($config);
     $this->setOptions($config);
     $taskPaths = $this->getLaravel()->make('\\Aimeos\\Shop\\Base\\Aimeos')->get()->getSetupPaths($template);
     $manager = new \Aimeos\MW\Setup\Manager\Multiple($ctx->getDatabaseManager(), $dbconfig, $taskPaths, $ctx);
     $this->info(sprintf('Initializing or updating the Aimeos database tables for site "%1$s"', $site));
     if (($task = $this->option('task')) && is_array($task)) {
         $task = reset($task);
     }
     switch ($this->option('action')) {
         case 'migrate':
             $manager->migrate($task);
             break;
         case 'rollback':
             $manager->rollback($task);
             break;
         case 'clean':
             $manager->clean($task);
             break;
         default:
             throw new \Exception(sprintf('Invalid setup action "%1$s"', $this->option('action')));
     }
 }
示例#3
0
    public function testRollback()
    {
        $expected = 'Executing TwoTask                                                     OK
';
        $taskPath = __DIR__ . DIRECTORY_SEPARATOR . 'tasks';
        $conf = array('db' => $this->config->get('resource/db', array()));
        $object = new \Aimeos\MW\Setup\Manager\Multiple($this->dbm, $conf, $taskPath);
        ob_start();
        $object->rollback('TwoTask');
        $result = ob_get_contents();
        ob_end_clean();
        $this->assertEquals($expected, $result);
    }
 /**
  * Initialize or update the Aimeos database tables
  *
  * After installing and updating the Aimeos package, the database structure
  * must be created or upgraded to the current version. Depending on the size
  * of the database, this may take a while.
  *
  * @param string $site Site for updating database entries
  * @param string $tplsite Template site for creating or updating database entries
  * @param array $option Optional setup configuration, name and value are separated by ":" like "setup/default/demo:1".
  * @param string|null $task Setup task name to execute
  * @param string $action Setup task action, e.g. "migrate", "rollback" or "clean"
  * @return void
  */
 public function setupCommand($site = 'default', $tplsite = 'default', array $option = array(), $task = null, $action = 'migrate')
 {
     $context = $this->objectManager->get('\\Aimeos\\Shop\\Base\\Context')->get(null, 'command');
     $context->setEditor('aimeos:setup');
     $config = $context->getConfig();
     $config->set('setup/site', $site);
     $dbconfig = $this->getDbConfig($config);
     $this->setOptions($config, $option);
     $taskPaths = $this->objectManager->get('\\Aimeos\\Shop\\Base\\Aimeos')->get()->getSetupPaths($tplsite);
     $manager = new \Aimeos\MW\Setup\Manager\Multiple($context->getDatabaseManager(), $dbconfig, $taskPaths, $context);
     $this->outputFormatted('Initializing or updating the Aimeos database tables for site <b>%s</b>', array($site));
     switch ($action) {
         case 'migrate':
             $manager->migrate($task);
             break;
         case 'rollback':
             $manager->rollback($task);
             break;
         case 'clean':
             $manager->clean($task);
             break;
         default:
             throw new \Exception(sprintf('Invalid setup action "%1$s"', $action));
     }
 }
示例#5
0
    $conf->set('setup/site', $site);
    $dbconfig = getDbConfig($conf);
    $ctx = getContext($conf);
    $dbm = $ctx->getDatabaseManager();
    $manager = new \Aimeos\MW\Setup\Manager\Multiple($dbm, $dbconfig, $taskPaths, $ctx);
    $action = isset($options['action']) ? $options['action'] : 'migrate';
    $task = isset($options['task']) ? $options['task'] : null;
    switch ($action) {
        case 'clean':
            $manager->clean($task);
            break;
        case 'migrate':
            $manager->migrate($task);
            break;
        case 'rollback':
            $manager->rollback($task);
            break;
        default:
            throw new \Exception(sprintf('Invalid action "%1$s"', $action));
    }
} catch (Throwable $t) {
    echo "\n\nCaught PHP error while processing setup";
    echo "\n\nMessage:\n";
    echo $t->getMessage();
    echo "\n\nStack trace:\n";
    echo $t->getTraceAsString();
    echo "\n\n";
    exit(1);
} catch (\Exception $e) {
    echo "\n\nCaught exception while processing setup";
    echo "\n\nMessage:\n";