Example #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');
     $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');
 }
Example #2
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');
 }
Example #3
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');
 }
Example #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($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');
 }
Example #5
0
        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();
    echo "\n\n";