Beispiel #1
0
 /**
  * Returns a new context object
  *
  * @param array $confPaths List of configuration paths from the bootstrap object
  * @param array $options Associative list of configuration options as key/value pairs
  * @return \Aimeos\MShop\Context\Item\Iface Context object
  */
 protected static function getContext(array $confPaths, array $options)
 {
     $config = array();
     $ctx = new \Aimeos\MShop\Context\Item\Standard();
     if (isset($options['config'])) {
         foreach ((array) $options['config'] as $path) {
             if (is_file($path)) {
                 $config = array_replace_recursive($config, require $path);
             } else {
                 $confPaths[] = $path;
             }
         }
     }
     $conf = new \Aimeos\MW\Config\PHPArray($config, $confPaths);
     $conf = new \Aimeos\MW\Config\Decorator\Memory($conf);
     if (($cfg = $conf->get('command')) !== null) {
         $conf = new \Aimeos\MW\Config\Decorator\Memory($conf, $cfg);
     }
     $ctx->setConfig($conf);
     $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);
     return $ctx;
 }
Beispiel #2
0
/**
 * Returns a new configuration object
 *
 * @param array $confPaths List of configuration paths from the bootstrap object
 * @param array $options Associative list of configuration options as key/value pairs
 * @return \Aimeos\MW\Config\Iface Configuration object
 */
function getConfig(array $confPaths, array $options)
{
    $config = array();
    if (isset($options['config'])) {
        foreach ((array) $options['config'] as $path) {
            if (is_file($path)) {
                $config = array_replace_recursive($config, require $path);
            } else {
                $confPaths[] = $path;
            }
        }
    }
    $conf = new \Aimeos\MW\Config\PHPArray($config, $confPaths);
    $conf = new \Aimeos\MW\Config\Decorator\Memory($conf);
    if (isset($options['option'])) {
        foreach ((array) $options['option'] as $option) {
            $parts = explode(':', $option);
            if (count($parts) !== 2) {
                printf("Invalid config option \"%1\$s\"\n", $option);
                usage();
            }
            $conf->set($parts[0], $parts[1]);
        }
    }
    return $conf;
}