Creates a new generator.

@param string $name name of the generator.
@param array $config generator configuration.
@return Generator the created generator.
@throws Exception if the generator is not found.
430696
public static function create($name, array $config = array())
    {
        if (!isset(self::$config->generators[$name])) {
            throw new Exception("Unknown generator '$name'.");
        }

        $generator = \Yii::createComponent(\CMap::mergeArray(self::$config->generators[$name], $config));
        $generator->init();

        foreach (self::$config->attributes as $attribute => $value) {
            if (property_exists($generator, $attribute)) {
                $generator->$attribute = $value;
            }
        }

        return $generator;
    }
923280
public function addCommand($name, $config = array())
    {
        $command = parent::addCommand($name, $config);

        $controller = $this->getController();

        if($controller->isEditable() && KStringInflector::isSingular($controller->getView()->getName())) {
            $command->disabled = true;
        }

        return $this;
    }
661739
public function setConfig($config = array()) 
    { 

    	if(is_array($config) ) {

    		if(!empty($config)) {
    			foreach($config as $key=>$value) {

    				$this->_config[$key] = $value;
    			}
    		}

     	} else {
    		
    		throw new Exception( "Invalid parameter");
    	}

    }
1059780
public function setup(array $config = [])
    {
        unset($config['request_params'], $config['request_context']);

        if (isset($config['query'])) {
            throw new Exception(translate('{query} can not be initialized'), 500, Exception::BADARGUMENTS);
        }

        if (isset($config['search']) && !is_callable($config['search'])) {
            throw new Exception(translate('{search} must be a callable'), 500, Exception::BADARGUMENTS);
        }

        if (!isset($config['data_source'])) {
            throw new Exception(translate('{data_source} must be a ActiveRecord objetc'), 500, Exception::BADARGUMENTS);
        } elseif (isset($config['data_source']) && !($config['data_source'] instanceof ActiveRecordInterface)) {
            throw new Exception(translate('{data_source} must be a ActiveRecord objetc'), 500, Exception::BADARGUMENTS);
        }

        foreach ($config as $property => $data) {
            if (property_exists($this, '_'.$property)) {
                $this->{'_'.$property} = $data;
            } elseif (property_exists($this, $property)) {
                $this->{$property} = $data;
            }
        }
    }
640078
public static function registerConfig($name, array $config) {
		if( empty($config['path']) ) {
			throw new \Exception('Missing a valid "path" in configuration of route "'.$name.'"');
		}
		
// 		$parameters = array();
// 		if( isset($config['parameters']) && is_array($config['parameters']) ) {
// 			foreach( $config['parameters'] as $paramName => $paramConfig ) {
// 				$parameters[] = CLIArgument::make($paramName, $paramConfig);
// 			}
// 		}
		$options = $config;
		unset($options['path'], $options['controller'], $options['parameters']);
		static::register($name, $config['path'], $config['controller'], array(), $options);
	}
122660
protected function loadConfiguration($name, Config $config)
    {
        $themeConfig = CompiledYamlFile::instance("themes://{$name}/{$name}" . YAML_EXT)->content();
        $config->joinDefaults("themes.{$name}", $themeConfig);
    }
68088
public function createConfigurator($name, HelperSet $helperSet, Config $globalConfig)
    {
        return $this->getFactoryObject($name)->createConfigurator($helperSet, $globalConfig);
    }
1254730
public function set($name = null, $config = null) {
		if (is_array($config)) {
			$this->_configurations[$name] = $config;
			return;
		}
		if ($config === false) {
			unset($this->_configurations[$name]);
		}
	}
1080069
public function getGenerator($name)
    {
        if ($this->hasGenerator($name) === false) {
            throw new \RuntimeException(sprintf('Generator not found: "%s".', $name));
        }

        return $this->generators[$name];
    }
317615
static public function setConfig($config)
        {
            if (!is_array($config)) {
                throw new Exception("Config must be an array.");
            }

            foreach ($config as $k => $v) {
                self::$_config[$k] = $v;
            }
        }
37118
public function newInstance(array $config)
    {
        $new_config = array_merge($this->default_config, $config);

        return new static($this->config_handler, $this->url, $new_config);
    }
1245105
public function prepareGenerator($config)
    {
        $all = $config->getAll();
        $context = new HTMLPurifier_Context();
        $this->generator = new HTMLPurifier_Generator($config, $context);
    }
1143657
public function create( $model, $config = [] ) {

		if( empty( $model->value ) ) {

			$model->value = $model->name;
		}

		return parent::create( $model, $config );
	}
1242096
public static function initPdoDatabase($config, $name)
    {
        try {
            $pdo = static::createPdoConnectionByConfig($config);
        } catch (PDOException $e) {
            throw new Exception('Cannon instantiate database connection: ' . $e->getMessage());
        }

        $pdo->uniqueName = $config['host'] . "-" . $config['db'];

        static::checkDebugBar($pdo, $name);

        return new RepositoryPDO($pdo, $name);
    }
562804
public function connect(array $config, string $name = 'main'): Connection
    {
        if (isset($this->connections[$name])) {
            throw new InvalidArgumentException("Connection [$name] is already configured.");
        }

        $this->connections[$name] = new Connection($config);

        return $this->connections[$name];
    }
1223360
public static function make($name, array $config): ServiceContainer
    {
        $namespace = self::studly($name);
        $application = "\\Liqunx\\Baidu\\{$namespace}\\Application";

        return new $application($config);
    }
1028437
public static function makeProxy(string $name, array $config)
    {
        $mode = $config['mode'];
        if ($mode == Macro::MASTER_SLAVE) {
            return new MysqlProxyMasterSlave($name, $config);
        } else {
            return false;
        }
    }