Starts the engine
@param array $config
@todo Check caching controller actions
325468
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 {
            $view = new View();

            $controller = static::getControllerClass();
            $controller->setView($view);
            $action = static::getAction();

            if (!in_array($action, $controller->getActions())) {
                ControllerException::invalidAction($action);
            }

            $params = static::getParams();
            static::authenticate($controller, $action, $params);
            $view->setController($controller)
                    ->setAction($action);

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

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

            if ($actionRet !== null && !is_array($actionRet) &&
                    (is_object($actionRet) && get_class($actionRet) !== 'DScribe\View\View')) {
                ControllerException::invalidActionResult();
            }

            if (is_array($actionRet))
                $view->variables($actionRet);
            elseif (is_object($actionRet))
                $view = $actionRet;
            ob_start();
            $view->render();
            $data = ob_get_clean();
            if ($cache && !Session::fetch('noCache'))
                $cache->save($name, $data);
            echo $data;
            static::terminate();
        }
    }
140640
public function initSession($config)
    {
        $sessionConfig = new SessionConfig();
        $sessionConfig->setOptions($config);
        $sessionManager = new SessionManager($sessionConfig);
        $sessionManager->start();
        Container::setDefaultManager($sessionManager);
    }
1328837
public function init( $config = [ ] )
    {
        if ( isset( $config[ 'error_callback' ] ) )
        {
            $this->errorCallback = $config[ 'error_callback' ];
        }

        if ( isset( $config[ 'exception_callback' ] ) )
        {
            $this->exceptionCallback = $config[ 'exception_callback' ];
        }

        if ( isset( $config[ 'shutdown_callback' ] ) )
        {
            $this->shutdownCallback = $config[ 'shutdown_callback' ];

            register_shutdown_function( $this->shutdownCallback );
        }

        set_error_handler( [ $this, 'handleError' ], E_ALL );

        set_exception_handler( [ $this, 'handleException' ] );
    }
912447
public function initialize(array $config) {
        $this->table('cms_content');
        $this->displayField('name');
        $this->primaryKey('id');
        $this->addBehavior('Timestamp', [
            'events' => [
                'Model.beforeSave' => [
                    'created' => 'new',
                    'modified' => 'always',
                ]
            ]
        ]);
        $this->hasMany('CmsContentMeta', [
            'foreignKey' => 'cms_content_id',
            'className' => 'Content.CmsContentMeta'
        ]);
        $this->hasMany('CmsPermission', [
            'foreignKey' => 'cms_content_id',
            'className' => 'Content.CmsPermission'
        ]);
        $this->hasMany('CmsTermRelation', [
            'foreignKey' => 'cms_content_id',
            'className' => 'Content.CmsTermRelation'
        ]);
    }
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;
    }
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;
    }
131933
public function initialize(array $config)
    {
        parent::initialize($config);

        $_config = [
            'context'  => __d('core', 'record'),
            'redirect' => [
                'action'     => 'index',
                'prefix'     => $this->_request->getParam('prefix'),
                'plugin'     => $this->_request->getParam('plugin'),
                'controller' => $this->_request->getParam('controller'),
            ],
            'messages' => [
                'no_action' => __d('core', 'Action not found.'),
                'no_choose' => __d('core', 'Please choose only one item.'),
            ]
        ];

        $config = Hash::merge($_config, $config);
        $this->setConfig($config);
    }
287586
protected function initialize(array $config)
    {
        $this->swooleServer = $this->createSwooleServer($config);

        $this->configureDefaultServerSocket();

        $this->setOptions($config['options'] ?? []);

        $this->registerEventCallbacks($this->serverEvents);

        $this->events->dispatch(new Events\ServerCreated($this));
    }
58077
public static function init(Config $config)
    {
        self::loadAvailableLanguages();

        // Try cookies first:
        if (isset($_COOKIE) && array_key_exists('phpcilang', $_COOKIE) && self::setLanguage($_COOKIE['phpcilang'])) {
            return;
        }

        // Try user language:
        if (isset($_SERVER) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
            $langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);

            foreach ($langs as $lang) {
                $parts = explode(';', $lang);
                $language = strtolower($parts[0]);

                if (self::setLanguage($language)) {
                    return;
                }
            }
        }

        // Try the installation default language:
        $language = $config->get('phpci.basic.language', null);
        if (self::setLanguage($language)) {
            return;
        }

        // Fall back to English:
        self::$language = 'en';
        self::$strings = self::loadLanguage();
    }
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.'
            );
        }
    }
1137129
public function initialize(array $config)
    {
        parent::initialize($config);

        $this->setController($this->_registry->getController());

        $this->_registerFromConfigure();
    }
204933
public function initialize(array $config)
    {
        $this->table('users');
        $this->displayField('email');
        $this->primaryKey('id');
        $this->addBehavior('Timestamp');

        $this->belongsTo('Roles', [
            'className' => 'CakeManager.Roles',
            'foreignKey' => 'role_id',
            'propertyName' => 'role',
        ]);
    }
800842
protected function loadConfig(array $config)
	{
		$this->className = $config['class'];
		$this->itemPerPage = (int) $config['item_per_page'];
		$this->maxPageNumber = (int) $config['max_page_number'];		
	}
1295443
public function initialize(array $config) {
		parent::initialize($config);

		$this->addBehavior('Timestamp');
		if (Configure::read('Queue.isSearchEnabled') !== false && Plugin::isLoaded('Search')) {
			$this->addBehavior('Search.Search');
		}

		$this->belongsTo('WorkerProcesses', [
			'className' => 'Queue.QueueProcesses',
			'foreignKey' => false,
			'conditions' => [
				'WorkerProcesses.workerkey = QueuedJobs.workerkey',
			],
		]);
	}
59220
public static function startProd(&$config) {
		self::$cacheDirectory = self::initialGetCacheDirectory ( $config );
		$cacheDirectory = \ROOT . \DS . self::$cacheDirectory;
		self::getCacheInstance ( $config, $cacheDirectory, ".cache" );
	}
841888
public function initialize(array $config)
    {
        $this->setTable($this->tablePrefix . $this->getTable());
        // HttpClient needs special header HTTP_X_UNIT_TEST_MODE => set in AppCakeTestCase::initHttpClient()
        if (isset($_SERVER['HTTP_X_UNIT_TEST_MODE'])
            || (php_sapi_name() == 'cli' && $_SERVER['argv'][0] && preg_match('/phpunit/', $_SERVER['argv'][0]))) {
            $this->setConnection(ConnectionManager::get('test'));
        }
        parent::initialize($config);
    }
706636
public function init( $config = [ ] )
    {
        $this->initDefaults();

        $this->initMail( $config );

        $this->initLog( $config );

        $this->initDatabase( $config );

        $this->initRequest( $config );

        $this->initRouter( $config );

        $this->initSession( $config );

        $this->initAppName( $config );

        $this->initDefaultLanguage( $config );

//        $this->_initMaintenanceMode( $config );
    }