示例#1
0
 /**
  * Executes the setup tasks for updating the database.
  *
  * The setup tasks print their information directly to the standard output.
  * To avoid this, it's necessary to use the output buffering handler
  * (ob_start(), ob_get_contents() and ob_end_clean()).
  */
 public static function execute()
 {
     ini_set('max_execution_time', 0);
     $aimeos = \Aimeos\Aimeos\Base::getAimeos();
     $sitecode = \Aimeos\Aimeos\Base::getExtConfig('siteCode', 'default');
     $taskPaths = $aimeos->getSetupPaths('default');
     $ctx = self::getContext();
     $dbm = $ctx->getDatabaseManager();
     $config = $ctx->getConfig();
     $config->set('setup/site', $sitecode);
     $dbconfig = $config->get('resource', array());
     foreach ($dbconfig as $rname => $dbconf) {
         if (strncmp($rname, 'db', 2) !== 0) {
             unset($dbconfig[$rname]);
         } else {
             $config->set("resource/{$rname}/limit", 2);
         }
     }
     $class = 'TYPO3\\CMS\\Extbase\\Object\\ObjectManager';
     $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($class);
     $utility = $objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\ConfigurationUtility');
     $conf = $utility->convertValuedToNestedConfiguration($utility->getCurrentConfiguration('aimeos'));
     $value = isset($conf['useDemoData']) ? $conf['useDemoData'] : '';
     $local = array('setup' => array('default' => array('demo' => (string) $value)));
     $ctx->setConfig(new \Aimeos\MW\Config\Decorator\Memory($config, $local));
     $manager = new \Aimeos\MW\Setup\Manager\Multiple($dbm, $dbconfig, $taskPaths, $ctx);
     $manager->migrate();
     $conf['useDemoData'] = '';
     $utility->writeConfiguration($conf, 'aimeos');
 }
示例#2
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')));
     }
 }
示例#3
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')));
     }
 }
示例#4
0
 /**
  * Executes the setup tasks for updating the database.
  *
  * The setup tasks print their information directly to the standard output.
  * To avoid this, it's necessary to use the output buffering handler
  * (ob_start(), ob_get_contents() and ob_end_clean()).
  */
 public static function execute()
 {
     ini_set('max_execution_time', 0);
     $aimeos = \Aimeos\Aimeos\Base::getAimeos();
     $sitecode = \Aimeos\Aimeos\Base::getExtConfig('siteCode', 'default');
     $taskPaths = $aimeos->getSetupPaths('default');
     $includePaths = $taskPaths;
     $includePaths[] = get_include_path();
     if (set_include_path(implode(PATH_SEPARATOR, $includePaths)) === false) {
         throw new Exception('Unable to extend include path');
     }
     if (spl_autoload_register('Aimeos\\Aimeos\\Setup::autoload') === false) {
         throw new Exception('Unable to register Aimeos\\Aimeos\\Setup::autoload');
     }
     $ctx = self::getContext();
     $dbm = $ctx->getDatabaseManager();
     $config = $ctx->getConfig();
     $local = array();
     $config->set('setup/site', $sitecode);
     $dbconfig = $config->get('resource', array());
     foreach ($dbconfig as $rname => $dbconf) {
         if (strncmp($rname, 'db', 2) !== 0) {
             unset($dbconfig[$rname]);
         } else {
             $config->set("resource/{$rname}/limit", 2);
         }
     }
     if (\Aimeos\Aimeos\Base::getExtConfig('useDemoData', 1) == 1) {
         $local = array('setup' => array('default' => array('demo' => true)));
     }
     $ctx->setConfig(new \Aimeos\MW\Config\Decorator\Memory($config, $local));
     $manager = new \Aimeos\MW\Setup\Manager\Multiple($dbm, $dbconfig, $taskPaths, $ctx);
     $manager->run('mysql');
 }
示例#5
0
    public function testClean()
    {
        $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->clean('TwoTask');
        $result = ob_get_contents();
        ob_end_clean();
        $this->assertEquals($expected, $result);
    }
示例#6
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $ctx = $this->getLaravel()->make('\\Aimeos\\Shop\\Base\\Context')->get(false);
     $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);
     $includePaths = $taskPaths;
     $includePaths[] = get_include_path();
     if (set_include_path(implode(PATH_SEPARATOR, $includePaths)) === false) {
         throw new Exception('Unable to extend include path');
     }
     $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));
     $manager->run('mysql');
 }
示例#7
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);
     $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);
     $includePaths = $taskPaths;
     $includePaths[] = get_include_path();
     if (set_include_path(implode(PATH_SEPARATOR, $includePaths)) === false) {
         throw new \Exception('Unable to extend include path');
     }
     spl_autoload_register('\\Aimeos\\ShopBundle\\Command\\SetupCommand::autoload', true);
     $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));
     $manager->run('mysql');
 }
示例#8
0
 /**
  * Executes the setup tasks for updating the database.
  *
  * The setup tasks print their information directly to the standard output.
  * To avoid this, it's necessary to use the output buffering handler
  * (ob_start(), ob_get_contents() and ob_end_clean()).
  */
 public static function execute()
 {
     ini_set('max_execution_time', 0);
     $aimeos = \Aimeos\Aimeos\Base::getAimeos();
     $sitecode = \Aimeos\Aimeos\Base::getExtConfig('siteCode', 'default');
     $taskPaths = $aimeos->getSetupPaths($sitecode);
     $includePaths = $taskPaths;
     $includePaths[] = get_include_path();
     if (set_include_path(implode(PATH_SEPARATOR, $includePaths)) === false) {
         throw new \Exception('Unable to extend include path');
     }
     if (spl_autoload_register('Aimeos\\Aimeos\\Setup::autoload') === false) {
         throw new \Exception('Unable to register Aimeos\\Aimeos\\Setup::autoload');
     }
     $ctx = self::getContext();
     $dbm = $ctx->getDatabaseManager();
     $config = $ctx->getConfig();
     $config->set('setup/site', $sitecode);
     $dbconfig = $config->get('resource', array());
     foreach ($dbconfig as $rname => $dbconf) {
         if (strncmp($rname, 'db', 2) !== 0) {
             unset($dbconfig[$rname]);
         } else {
             $config->set("resource/{$rname}/limit", 2);
         }
     }
     $class = '\\TYPO3\\CMS\\Extbase\\Object\\ObjectManager';
     $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($class);
     $utility = $objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\ConfigurationUtility');
     $conf = $utility->getCurrentConfiguration('aimeos');
     $local = array('setup' => array('default' => array('demo' => (string) $conf['useDemoData'])));
     $ctx->setConfig(new \Aimeos\MW\Config\Decorator\Memory($config, $local));
     $manager = new \Aimeos\MW\Setup\Manager\Multiple($dbm, $dbconfig, $taskPaths, $ctx);
     $manager->run('mysql');
     $conf['useDemoData'] = '';
     $utility->writeConfiguration($conf, 'aimeos');
 }
示例#9
0
    foreach ($dbconfig as $rname => $dbconf) {
        if (strncmp($rname, 'db', 2) !== 0) {
            unset($dbconfig[$rname]);
        } else {
            $conf->set("resource/{$rname}/limit", 2);
        }
    }
    $dbm = new \Aimeos\MW\DB\Manager\PDO($conf);
    $ctx->setDatabaseManager($dbm);
    $logger = new \Aimeos\MW\Logger\Errorlog(\Aimeos\MW\Logger\Base::INFO);
    $ctx->setLogger($logger);
    $session = new \Aimeos\MW\Session\None();
    $ctx->setSession($session);
    $cache = new \Aimeos\MW\Cache\None();
    $ctx->setCache($cache);
    $manager = new \Aimeos\MW\Setup\Manager\Multiple($dbm, $dbconfig, $taskPaths, $ctx);
    $manager->run('mysql');
} 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";
    echo $e->getMessage();
    echo "\n\nStack trace:\n";
    echo $e->getTraceAsString();
 /**
  * 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));
     }
 }
示例#11
0
     $site = 'default';
 }
 if (($tplsite = array_shift($params)) === null) {
     $tplsite = 'default';
 }
 spl_autoload_register('setupAutoload');
 require 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
 $aimeos = new \Aimeos\Bootstrap(isset($options['extdir']) ? (array) $options['extdir'] : array());
 $taskPaths = $aimeos->getSetupPaths($tplsite);
 setIncludePaths($taskPaths);
 $conf = getConfig($aimeos->getConfigPaths(), $options);
 $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));
 }