Creates and runs a specific generator.

@param string $name name of the generator.
@param array $config generator configuration.
@return File[] list of files to generate.
506053
public static function run($name, array $config = array())
    {
        $generator = self::create($name, $config);

        if (!$generator->validate()) {
            $generator->renderErrors();
        }

        return $generator->generate();
    }
316407
protected function loadConfiguration(Structure $config, $name = null)
    {
        $name = $name ?: $this->getName();

        // Load library config
        $configName = $this->isWeb() ? 'web' : 'console';

        $config->loadFile(__DIR__ . '/../../config/' . $configName . '.php', 'php', ['load_raw' => true]);

        // Load application config
        $file = $this->rootPath . '/etc/app/' . $name . '.php';

        if (is_file($file)) {
            $config->loadFile($file, 'php', ['load_raw' => true]);
        }

        $configs = (array) $config->get('configs', []);

        ksort($configs);

        foreach ($configs as $file) {
            if ($file === false || !is_file($file)) {
                continue;
            }

            $config->loadFile($file, pathinfo($file, PATHINFO_EXTENSION), ['load_raw' => true]);
        }

        $this->container->setParameters($config);
    }
457651
private function load_config_file( $dir, $name ) {
		$path = rtrim( $dir, DS ) . DS . $name . '.php';
		if ( ! file_exists( $path ) ) {
			return [];
		}
		/** @noinspection PhpIncludeInspection */
		$config = include $path;
		if ( ! is_array( $config ) ) {
			$config = [];
		}

		return $config;
	}
299718
public function generate(Config $config)
    {
        $parts = array();
        if ($config->parent) {
            $parts[] = str_replace(
                array('{id}', '.{_format}'),
                array(sprintf('{%sId}', $this->getPrefix($config->parent)), ''),
                $this->generate($config->parent)
            );
        }
        $parts[] = $this->getPrefix($config);

        $prefix = implode('/', array_filter($parts));
        $pattern = $this->getPattern($config);

        if (isset($pattern[0]) && '/' !== $pattern[0] && '.' !== $pattern[0]) {
            return rtrim($prefix, '/').'/'.$pattern;
        }

        return $prefix.$pattern;
    }
95191
public function appendExtension($name, array $config = [])
    {
        $merged = array_merge_recursive(
            $this->getExtension($name),
            $config
        );

        $this->addExtension($name, $merged);
    }
1309747
protected function configSplit($name, $config = 'default'): array
    {
        if (strpos($name, ':') !== false) {
            $parts = explode(':', $name, 2);

            return $parts;
        }

        return [$config, $name];
    }
1343130
public function createGateway($name, array $config = array())
    {
        if (!isset($this->gateways[$name])) {
            throw new CException(sprintf('Failed to create payment gateway "%s".', $name));
        }
        $config = CMap::mergeArray($this->gateways[$name], $config);
        $gateway = Yii::createComponent($config);
        $gateway->manager = $this;
        $gateway->init();
        return $gateway;
    }
70526
public static function getConfigFiles(array $names, $configDir = null)
    {
        $dirs = ($configDir === null) ? self::getConfigDirs() : [$configDir];

        return self::getRealFiles($dirs, $names);
    }
268821
public function generate(Config $config)
    {
        $parts = array();
        if ($config->parent) {
            $parent = $config->parent->isRepresentant() ? $config->parent->parent : $config->parent;
            $parts[] = $this->generate($parent);
        }

        $parts[] = $this->getPrefix($config);

        return implode('_', array_filter($parts));
    }
1005532
public static function makeProxy(string $name, array $config)
    {
        $mode = $config['mode'];
        if ($mode == Macro::CLUSTER) {
            return new RedisProxyCluster($name, $config);
        } elseif ($mode == Macro::MASTER_SLAVE) {
            return new RedisProxyMasterSlave($name, $config);
        } else {
            return false;
        }
    }
611328
private function makeWriters(array $config): array
    {
        $writers = [];

        foreach ($config as $name => $binding) {
            $writers[$name] = $binding->resolve($this->factory);
        }

        return $writers;
    }
357510
protected function createFileDriver(string $name, Prop $config)
	{
		return new FileStore(
			Filesystem::getInstance(),
			$name,
			$config->getOr("directory", "cache"),
			$config->getOr("life", 0)
		);
	}
203703
public static function create(array $config, $name = 'default')
    {
        // Make sure a connection with same name doesn't exist
        if (array_key_exists($name, static::$connections)) {
            throw new Exception("Database connection {$name} already exists.");
        }

        // Set the class name, with the namespace
        $className = '\Radium\Database\\'. $config['driver'];

        // Connect to the database and return the object
        static::$connections[$name] = new $className($config, $name);
        return static::$connections[$name];
    }
671390
public static function createFromConfig(array $config)
    {
        $manager = static::createEmptyFromConfig($config);

        $manager->addCollection(new CssCollection)
                ->addCollection(new JavascriptCollection);

        return $manager;
       
    }
1287332
public function connect($config = [], $name = false)
    {
        $this->connection = Connection::instance($config, $name);
        $query            = $this->connection->getConfig('query');

        if (__CLASS__ != trim($query, '\\')) {
            return new $query($this->connection);
        }

        $this->prefix = $this->connection->getConfig('prefix');

        return $this;
    }
1220424
public function getRequiredFiles($config)
    {
        $files = [];
        
        foreach ($config as $key => $name) {
            
            if (is_numeric($key) && is_string($name)) {
                
                $files[] = $name;
                
            } elseif (is_numeric($key) && is_array($name)) {
                
                foreach ($name as $module => $file) {
                    $files[] = sprintf('%s: %s', $module, $file);
                }
                
            } elseif (!is_numeric($key) && is_array($name)) {
                
                foreach ($name as $file) {
                    $files[] = sprintf('%s: %s', $key, $file);
                }
                
            }
            
        }
        
        return $files;
    }
31801
public function load(array $files, Config $config = null)
    {
        if (is_null($config)) {
            $config = new Config();
        }

        if (!$this->isValidFileList($files)) {
            throw new \RuntimeException('Invalid config file list given. At least one config file must exist.');
        }

        foreach ($files as $file) {
            if ($this->isFileExisting($file)) {
                $config->merge(
                    $this->loadFile($file)
                );
            }
        }

        return $config;
    }