src/Koldy/Security/Csrf.php
public static function init(array $config = null, bool $reInit = false)
    {
        if (static::$config === null || $reInit) {
            if ($config === null) {
                $config = Application::getConfig('application');
                static::$config = $config->getArrayItem('security', 'csrf', [
                  //self::ENABLED => false,
                  self::PARAMETER_NAME => 'csrf',
                  self::COOKIE_NAME => 'csrf_token',
                  self::SESSION_KEY_NAME => 'csrf_token'
                ]);
            } else {
                static::$config = $config;
            }

            /* // CSRF is not started by default by framework any more
            if (!array_key_exists(self::ENABLED, static::$config)) {
                throw new ConfigException('Missing key \'enabled\' in security/CSRF config');
            }
            */

            //if (static::$config['enabled']) {
                // check CSRF config

                foreach ([self::PARAMETER_NAME, self::COOKIE_NAME, self::SESSION_KEY_NAME] as $key) {
                    if (!array_key_exists($key, static::$config)) {
                        throw new ConfigException("Missing {$key} key in security/CSRF config");
                    }
                }
            //}
        }
    }
public static function init(array $config = null, bool $reInit = false)
    {
        if (static::$config === null || $reInit) {
            if ($config === null) {
                $config = Application::getConfig('application');
                static::$config = $config->getArrayItem('security', 'csrf', [
                  //self::ENABLED => false,
                  self::PARAMETER_NAME => 'csrf',
                  self::COOKIE_NAME => 'csrf_token',
                  self::SESSION_KEY_NAME => 'csrf_token'
                ]);
            } else {
                static::$config = $config;
            }

            /* // CSRF is not started by default by framework any more
            if (!array_key_exists(self::ENABLED, static::$config)) {
                throw new ConfigException('Missing key \'enabled\' in security/CSRF config');
            }
            */

            //if (static::$config['enabled']) {
                // check CSRF config

                foreach ([self::PARAMETER_NAME, self::COOKIE_NAME, self::SESSION_KEY_NAME] as $key) {
                    if (!array_key_exists($key, static::$config)) {
                        throw new ConfigException("Missing {$key} key in security/CSRF config");
                    }
                }
            //}
        }
    }
public static function init ( array $ config = null , bool $ reInit = false ) { if ( static :: $ config === null || $ reInit ) { if ( $ config === null ) { $ config = Application :: getConfig ( 'application' ) ; static :: $ config = $ config -> getArrayItem ( 'security' , 'csrf' , [ //self::ENABLED => false, self :: PARAMETER_NAME => 'csrf' , self :: COOKIE_NAME => 'csrf_token' , self :: SESSION_KEY_NAME => 'csrf_token' ] ) ; } else { static :: $ config = $ config ; } /* // CSRF is not started by default by framework any more
            if (!array_key_exists(self::ENABLED, static::$config)) {
                throw new ConfigException('Missing key \'enabled\' in security/CSRF config');
            }
            */ //if (static::$config['enabled']) { // check CSRF config foreach ( [ self :: PARAMETER_NAME , self :: COOKIE_NAME , self :: SESSION_KEY_NAME ] as $ key ) { if ( ! array_key_exists ( $ key , static :: $ config ) ) { throw new ConfigException ( "Missing {$key} key in security/CSRF config" ) ; } } //} } }
Initialize CSRF config

@param array $config
@param bool $reInit

@throws ConfigException
@throws \Koldy\Exception
Initialize CSRF config