Starts the engine
@param array $config
@todo Check caching controller actions
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));
        }
    }
510153
public function initialize(array $config)
    {
        $this->_controller = $this->_registry->getController();
        $this->_request    = $this->_controller->request;

        parent::initialize($config);
    }
300877
public static function start(&$config)
    {
        self::$config = &$config;
        self::$instance = new StandardDebugBar();
        self::$renderer = self::$instance->getJavascriptRenderer();
        self::$renderer->setOptions(self::$config);

        self::$atomikMessages = new \DebugBar\DataCollector\MessagesCollector('atomik');
        self::$instance['messages']->aggregate(self::$atomikMessages);

        Atomik::set('debugbar', self::$instance);
        Atomik::registerHelper('renderDebugBar', array(self::$renderer, 'render'));
        Atomik::registerHelper('renderDebugBarHead', array(self::$renderer, 'renderHead'));
    }
72883
public function initTasks(array $config)
    {
        foreach ($config as $taskName => $taskConfig) {
            $this->initTask($taskName, $taskConfig);
        }
    }
1228151
public function initialize(array $config = [])
    {
        $this->setConfig($config);
        $this->_registry->getController()->viewBuilder()->setHelpers(['Recaptcha.Recaptcha' => $this->_config]);
    }
267238
public function initialize(array $config)
    {
        parent::initialize($config);

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

        $this->_addFromConfigure();

        // set up the default helper
        $this->Controller->helpers['Utils.Menu'] = [];
    }
1235928
public function initialize(array $config)
    {
        $controller = $this->_registry->getController();
        $this->setEventManager($controller->getEventManager());
        $this->response =& $controller->response;
        $this->session = $controller->getRequest()->getSession();

        if ($this->getConfig('ajaxLogin')) {
            deprecationWarning(
                'The `ajaxLogin` option is deprecated. Your client-side ' .
                'code should instead check for 403 status code and show ' .
                'appropriate login form.'
            );
        }
    }
528742
public function initialize(array $config) {
        $this->config = $config;
        $this->controller = $this->_registry->getController();
        $registry = new ComponentRegistry();
        $this->Acl = new AclComponent($registry, Configure::read('Acl'));
        $this->Aco = $this->Acl->Aco;
        $this->Aro = $this->Acl->Aro;
        return null;
    }
1216216
public function initiate(array $config): void
    {
        $this->fieldsets = new Collection();

        foreach ($config as $key => $value) {
            if (\property_exists($this, $key)) {
                $this->{$key} = $value;
            }
        }

        $this->data = new Fluent();
    }
399369
public function initialize(array $config)
    {
        parent::initialize($config);

        $this->table('users');
        $this->displayField('username');
        $this->primaryKey('id');

        $this->addBehavior('Timestamp');
        $this->addBehavior('Muffin/Trash.Trash');
        $this->addBehavior('Muffin/Tokenize.Tokenize');

        if (Plugin::loaded('Search')) {
            $this->addBehavior('Search.Search');
        }
    }
475063
public function initialize(array $config = [])
    {
        $config = array_merge($this->config, $config);

        if (empty($this->engine)) {
            $this->engine = new \O2System\Parser\String\Engines\Shortcodes($config);
        }

        return $this;
    }
208352
public function initiate(array $config): void
    {
        foreach ($config as $key => $value) {
            if (\property_exists($this, $key)) {
                $this->{$key} = $value;
            }
        }

        $this->header(function () {
            return [];
        });
    }
1074321
public static function boot(array $config)
    {
        if (self::$booted) {
            return;
        }
        
        /**
         * Loader.
         */
        if (!isset($config['loader'])) {
            throw new BadMethodCallException(
                'Requires at least loader instance or configuration'
            );
        } else {
            if (is_array($config['loader'])) {
                // require_once __DIR__ . '/Rails/Loader/Loader.php';
                $loader = new Rails\Loader\Loader();
                
                if (isset($config['loader']['paths'])) {
                    $loader->addPaths($config['loader']['paths']);
                }
                
                if (isset($config['loader']['composerAutoloader'])) {
                    $loader->setComposerAutoloader(
                        $config['loader']['composerAutoloader']
                    );
                } else {
                    $loader->addPath(__DIR__ . '/Rails');
                }
                $loader->register();
            } elseif ($config['loader'] instanceof Rails\Loader\Loader) {
                $loader = $config['loader'];
            } else {
                throw new InvalidArgumentException(
                    sprintf(
                        'Loader must be either array or instance of Rails\Loader\Loader, %s passed',
                        gettype($config['loader'])
                    )
                );
            }
        }
        
        /**
         * Service Manager.
         */
        $sm = new Zend\ServiceManager\ServiceManager();
        self::$serviceManager = $sm;
        $sm->setService('loader', $loader);
        
        /**
         * Global configuration.
         */
        $sm->setService('rails.config', new Rails\ActiveSupport\ArrayObject([
            'use_cache' => false
        ]));
        
        /**
         * Inflector.
         */
        $sm->setFactory('inflector', function() {
            return new Rails\ActiveSupport\Inflector\Inflector(
                new Rails\ActiveSupport\Inflector\Inflections\EnglishInflections,
                'en'
            );
        });
        
        /**
         * Translator.
         */
        $sm->setFactory('i18n', function() {
            $tr = new Rails\I18n\LoadingTranslator();
            $tr->setDefaultLocale('en');
            $tr->setLoader(new Rails\I18n\Loader());
            
            
            # Add Rails' locales paths to i18n loader
            $tr->loader()->addPaths([
                __DIR__ . '/Rails/ActiveSupport/Carbon/locales',
                __DIR__ . '/Rails/I18n/locales',
            ]);
            
            return $tr;
        });
        
        self::$booted = true;
    }
364971
public function init( $config = [ ] )
    {
        if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) )
        {
            $this->userAgent = $_SERVER[ 'HTTP_USER_AGENT' ];
        }
        if ( isset( $_SERVER[ 'SERVER_NAME' ] ) )
        {
            $this->server = $_SERVER[ 'SERVER_NAME' ];
        }
        if ( isset( $_SERVER[ 'SERVER_PORT' ] ) )
        {
            $this->port = $_SERVER[ 'SERVER_PORT' ];
        }
        if ( isset( $_SERVER[ 'REQUEST_METHOD' ] ) )
        {
            $this->method = $_SERVER[ 'REQUEST_METHOD' ];
        }
        if ( isset( $_SERVER[ 'QUERY_STRING' ] ) )
        {
            $this->query = $_SERVER[ 'QUERY_STRING' ];
        }
        if ( isset( $_SERVER[ 'SCRIPT_NAME' ] ) )
        {
            $this->script = $_SERVER[ 'SCRIPT_NAME' ];
        }
        if ( isset( $_SERVER[ 'REQUEST_URI' ] ) )
        {
            $this->requestUri = $_SERVER[ 'REQUEST_URI' ];
        }
        if ( isset( $_SERVER[ 'REQUEST_SCHEME' ] ) )
        {
            $this->scheme = $_SERVER[ 'REQUEST_SCHEME' ];
        }

        $request = str_replace( $_SERVER[ 'SCRIPT_NAME' ], '', $this->requestUri );

        $elements = explode( '/', $request );

        if ( '' === $elements[ 0 ] )
        {
            array_shift( $elements );
        }

        if ( 2 <= count( $elements ) )
        {
            $this->route = $elements[ 0 ] . '/' . $elements[ 1 ];

            array_shift( $elements );
            array_shift( $elements );

            if ( 0 < count( $elements ) )
            {
                $this->params = $elements;
            }
        }
        else if ( 1 === count( $elements ) )
        {
            $this->route = $elements[ 0 ];

            array_shift( $elements );
        }
    }
127689
public function initialize(array $config)
    {
        parent::initialize($config);

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

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

        $this->belongsTo('Users', ['className' => 'MeCms.Users'])
            ->setForeignKey('user_id')
            ->setJoinType('INNER');

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

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

        $this->_validatorClass = PostValidator::class;
    }
555485
public static function startDatabase(&$config) {
		$db = $config ['database'] ?? [ ];
		if ($db ['dbName'] !== '') {
			self::connect ( $db ['type'], $db ['dbName'], $db ['serverName'] ?? '127.0.0.1', $db ['port'] ?? 3306, $db ['user'] ?? 'root', $db ['password'] ?? '', $db ['options'] ?? [ ], $db ['cache'] ?? false);
		}
	}
878392
protected function initializeConfig(array $config = null)
    {
        $default = $this->defaultConfigurations();

        $this->config = $config ? array_replace_recursive($default, $config) : $default;
    }