@param array $config

@throws RouterException
199160
protected function treatRoutesConfig(array $config): void
    {
        if (!\array_key_exists('routes', $config)) {
            return;
        }

        if (!\is_array($config['routes'])) {
            throw new RouterException('Config routes has to be an array');
        }

        foreach ($config['routes'] as $route) {
            if (!\array_key_exists('methods', $route)) {
                throw new RouterException('Config routes/methods is mandatory');
            }

            if (!\array_key_exists('url', $route)) {
                throw new RouterException('Config routes/url is mandatory');
            }

            if (!\array_key_exists('callback', $route)) {
                throw new RouterException('Config routes/callback is mandatory');
            }

            $newRoute = new Route($route['methods'], $route['url'], $route['callback']);

            if (\array_key_exists('constraints', $route)) {
                $newRoute->setParametersConstraints($route['constraints']);
            }

            if (\array_key_exists('middlewares', $route)) {
                if (!\is_array($route['middlewares'])) {
                    throw new RouterException('Config routes/middlewares has to be an array');
                }

                foreach ($route['middlewares'] as $middleware) {
                    $newRoute->addMiddleware($middleware);
                }
            }

            if (\array_key_exists('name', $route)) {
                if (!\is_string($route['name'])) {
                    throw new RouterException('Config routes/name has to be a string');
                }

                $newRoute->setName($route['name']);
            }

            if (\array_key_exists('host', $route)) {
                if (!\is_string($route['host'])) {
                    throw new RouterException('Config routes/host has to be a string');
                }

                $newRoute->setHost($route['host']);
            }

            if (\array_key_exists('host_constraints', $route)) {
                if (!\is_array($route['host_constraints'])) {
                    throw new RouterException('Config routes/host_constraints has to be an array');
                }

                $newRoute->setHostConstraints($route['host_constraints']);
            }

            if (\array_key_exists('optionals_parameters', $route)) {
                if (!\is_array($route['optionals_parameters'])) {
                    throw new RouterException('Config routes/optionals_parameters has to be an array');
                }

                $newRoute->setOptionalsParameters($route['optionals_parameters']);
            }

            $this->addRoute($newRoute);
        }
    }
681957
protected function initRouter( array $config )
    {
        if ( isset( $config[ 'router' ] ) )
        {
            if ( isset( $config[ 'router' ][ 'class' ] ) )
            {
                $this->bindShared( 'RawPHP\RawRouter\Contract\IRouter', function () use ( $config )
                {
                    $class = $config[ 'router' ][ 'class' ];

                    return new $class( $config[ 'router' ] );
                }
                );
            }
            else
            {
                $this->bindShared( 'RawPHP\RawRouter\Contract\IRouter', function () use ( $config )
                {
                    return new Router( $config[ 'router' ] );
                }
                );
            }
        }
        else
        {
            $this->bindShared( 'RawPHP\RawRouter\Contract\IRouter', function ()
            {
                return new Router();
            }
            );
        }

        $this->alias( 'RawPHP\RawRouter\Contract\IRouter', 'RawPHP\RawRouter\Router' );
        $this->alias( 'RawPHP\RawRouter\Contract\IRouter', 'router' );

        $this[ 'router' ]->setDispatcher( $this[ 'dispatcher' ] );

        $this->defaultController = $this[ 'router' ]->getDefaultController();
        $this->defaultAction     = $this[ 'router' ]->getDefaultAction();
    }
1164275
public function initialize(array $config)
    {
        //Checks for KCFinder and for the files directory (`APP/webroot/files`)
        is_true_or_fail($this->kcFinderIsAvailable(), __d('me_tools', '{0} is not available', 'KCFinder'));
        is_true_or_fail($this->uploadedDirIsWriteable(), __d('me_tools', 'File or directory `{0}` is not writable', rtr(UPLOADED)), NotWritableException::class);

        //Merges and writes on session:
        //  1) default config;
        //  2) options from configuration;
        //  3) passed options.
        $config = array_merge($this->getDefaultConfig(), getConfig('kcfinder', []), $config);
        $this->getController()->request->getSession()->write('KCFINDER', $config);

        parent::initialize($config);
    }
229211
public function setConfig($config)
    {
        $this->config = $config;

        $this->routes = $config['routes'];
        $this->options = $config['options'];

        return $this;
    }
50115
public function loadConfig(array $config)
    {
        $this->devServerEnabled = $config['dev_server_enable'];
        $this->devServerHost = $config['dev_server_host'];
        $this->devServerPort = $config['dev_server_port'];
    }
50265
public function initialize(array $config)
    {
        parent::initialize($config);

        $this->setTable('tags');
        $this->setDisplayField('tag');
        $this->setPrimaryKey('id');

        $this->belongsToMany('Posts', ['className' => 'MeCms.Posts', 'joinTable' => 'posts_tags'])
            ->setForeignKey('tag_id')
            ->setTargetForeignKey('post_id')
            ->setThrough('MeCms.PostsTags');

        $this->addBehavior('Timestamp');

        $this->_validatorClass = TagValidator::class;
    }
708845
public function initialize(array $config)
    {
        parent::initialize($config);

        $this->Controller = $this->_registry->getController();

        if ($this->config('Auth')) {
            $this->Controller->loadComponent('Auth', $this->config('Auth'));
        }

        $this->Controller->loadComponent('Utils.Menu');
    }
577135
protected function setParsedConfig(array $config)
    {
        foreach ($config as $key => $value) {
            $setter = 'set'.ucfirst($key);
            $this->$setter($value);
        }
    }
1139179
public function connect(array $config){
		Connection::alias($config, 'database', 'file');
		Connection::alias($config, 'updateLimit', 'update_limit');

		$defaults = array(
			'memory' => false,
			'resource' => null,
			'updateLimit' => false,
			'charset' => 'UTF-8',
			'dbcharset' => 'UTF-8'
		);

		$config += $defaults;

		if($config['memory'])
			$config['database'] = ':memory:';

		// Connect
		if($config['resource'] instanceof SQLite3)
			$connection = $config['resource'];
		elseif(!isset($config['database']))
			throw new DriverException("No database file selected.");
		else{
			try{
				$connection = new SQLite3($config['database']);
			} catch(Exception $e){
				throw new DriverException($e->getMessage(), $e->getCode());
			}
		}

		if(!$connection instanceof SQLite3)
			throw new DriverException("Opening database file '$config[database]' failed.");

		$this->resource = $connection;
		$this->updateLimit = (bool) $config['updateLimit'];

		// Set charset
		$this->dbCharset = $config['dbcharset'];
		$this->charset = $config['charset'];
		if(strcasecmp($this->dbCharset, $this->charset) === 0)
			$this->dbCharset = $this->charset = null;
	}
87421
static public function setConfig($config)
    {
        if ($config instanceof Zend_Config) {
            $config = $config->toArray();
        } elseif (!is_array($config)) {
            throw new Zend_Uri_Exception("Config must be an array or an instance of Zend_Config.");
        }

        foreach ($config as $k => $v) {
            self::$_config[$k] = $v;
        }
    }
1263908
public function addRedisPoolRoutes($config)
    {
        foreach ($config as $key => $value) {
            $this->route_map[$key] = $value;
        }
    }
1078408
public function initialize(array $config)
    {
        parent::initialize($config);

        $this->setTable('pages');
        $this->setDisplayField('title');
        $this->setPrimaryKey('id');

        $this->belongsTo('Categories', ['className' => 'MeCms.PagesCategories'])
            ->setForeignKey('category_id')
            ->setJoinType('INNER')
            ->setTarget($this->getTableLocator()->get('MeCms.PagesCategories'))
            ->setAlias('Categories');

        $this->addBehavior('Timestamp');
        $this->addBehavior('CounterCache', ['Categories' => ['page_count']]);

        $this->_validatorClass = PageValidator::class;
    }
353970
public static function run(array $config) {
        static::init($config);
        static::moduleIsActivated();
        $cache = static::canCache();
        $name = join('/', static::getUrls());
        if ($cache && $out = $cache->fetch($name)) {
            echo $out;
        }
        else {
            $controller = static::getControllerClass();
            $action = static::getAction();
            if (!in_array($action, $controller->getActions())) {
                ControllerException::invalidAction($action);
            }

            $params = static::getParams();
            static::authenticate($controller, $action, $params);

            $refMethod = new ReflectionMethod($controller, $action . 'Action');

            if (count($params) < $refMethod->getNumberOfRequiredParameters()) {
                ControllerException::invalidParamCount();
            }
            $actionRet = call_user_func_array(array($controller, $action . 'Action'), $params);

            if (!is_array($actionRet)) {
                ControllerException::invalidActionResult();
            }
            static::terminate();
            
            header('Content-Type: application/json');
            die(json_encode($actionRet));
        }
    }
1227839
public function initRoutes(Config $config)
    {
        //setups router
        $routerAdapter = new Standard($this->getDI());
        $router = new Router($this->getDI(), $routerAdapter);

        //adds routes defined in modules
        $modules = $this->getApplication()->getModules();
        foreach ($modules as $module) {
            $router->addModuleRoutes($module);
        }

        //adds routes defined in default file
        $defaultRoutesFile = $config->application->configDir
            . DIRECTORY_SEPARATOR
            . 'routes.php';
        if (file_exists($defaultRoutesFile)) {
            $routes = require $defaultRoutesFile;
            if (is_array($routes)) {
                $router->addRoutes($routes);
            }
        }

        //setup router rules
        $router->setup();

        //registers router into DI
        $this->getDI()->set('router', $router->getRouter());
    }
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;
            }
        }
870346
protected function configure(array $config)
	{
		if (isset($config['parsers']))
		{
			$this->registerParsers($config['parsers']);
		}

		if (isset($config['cache']))
		{
			$this->cachePath = rtrim('cache', '\\/').DIRECTORY_SEPARATOR;
		}

		if (isset($config['auto_filter']))
		{
			$this->autoFilter = (bool) $config['auto_filter'];
		}

		if (isset($config['view_folder']))
		{
			$this->setViewFolder($config['view_folder']);
		}

		if (isset($config['whitelist']))
		{
			$this->whitelist($config['whitelist']);
		}
	}
1136081
public function load(array $routesConfig)
    {
        foreach ($routesConfig as $route) {
            $pattern = $route[0];
            $handler = $route[1] ?? null;
            $methods = $route[2] ?? '*';
            $this->map($pattern, $handler, $methods);
        }
        return $this->routes;
    }