示例#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 \MW_Config_Decorator_Memory($config, $local));
     $manager = new \MW_Setup_Manager_Multiple($dbm, $dbconfig, $taskPaths, $ctx);
     $manager->run('mysql');
 }
示例#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');
     $config->set('setup/site', $site);
     $dbconfig = $this->getDbConfig($config);
     $this->setOptions($config);
     $taskPaths = $this->getLaravel()->make('\\Aimeos\\Shop\\Base\\Aimeos')->get()->getSetupPaths($site);
     $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\\Shop\\Command\\SetupCommand::autoload', true);
     $manager = new \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');
 }
示例#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') ?: $site;
     $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 \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');
 }
示例#4
0
            }
            $conf->set($parts[0], $parts[1]);
        }
    }
    $dbconfig = $conf->get('resource', array());
    foreach ($dbconfig as $rname => $dbconf) {
        if (strncmp($rname, 'db', 2) !== 0) {
            unset($dbconfig[$rname]);
        } else {
            $conf->set("resource/{$rname}/limit", 2);
        }
    }
    $dbm = new MW_DB_Manager_PDO($conf);
    $ctx->setDatabaseManager($dbm);
    $logger = new MW_Logger_Errorlog(MW_Logger_ABSTRACT::INFO);
    $ctx->setLogger($logger);
    $session = new MW_Session_None();
    $ctx->setSession($session);
    $manager = new MW_Setup_Manager_Multiple($dbm, $dbconfig, $taskPaths, $ctx);
    $manager->run('mysql');
} 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";
    exit(1);
}
$exectimeStop = microtime(true);
printf("Setup process took %1\$f sec\n\n", $exectimeStop - $exectimeStart);
 /**
  * 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|null $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".
  * @return void
  */
 public function setupCommand($site = 'default', $tplsite = null, array $option = array())
 {
     $context = $this->objectManager->get('\\Aimeos\\Shop\\Base\\Context')->get();
     $context->setEditor('aimeos:setup');
     $config = $context->getConfig();
     $config->set('setup/site', $site);
     $dbconfig = $this->getDbConfig($config);
     $this->setOptions($config, $option);
     $tplsite = $tplsite ?: $site;
     $taskPaths = $this->objectManager->get('\\Aimeos\\Shop\\Base\\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\\Shop\\Command\\AimeosCommandController::autoload', true);
     $manager = new \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));
     $manager->run('mysql');
 }