Filters
extends BaseConfig
in package
Filters configuration
Table of Contents
Properties
- $aliases : array<string, class-string|array<int, class-string>>
- Configures aliases for Filter classes to make reading things nicer and simpler.
- $filters : array<string|int, mixed>
- List of filter aliases that should run on any before or after URI patterns.
- $globals : array<string, array<string, array<string, string>>>|array<string, array<int, string>>
- List of filter aliases that are always applied before and after every request.
- $methods : array<string, array<int, string>>
- List of filter aliases that works on a particular HTTP method (GET, POST, etc.).
- $override : bool
- Whether to override properties by Env vars and Registrars.
- $registrars : array<string|int, mixed>
- An optional array of classes that will act as Registrars for rapidly setting config class properties.
-
$required
: array{before: list
, after: list } - List of special required filters.
- $didDiscovery : bool
- Has module discovery happened yet?
- $moduleConfig : Modules|null
- The modules configuration.
Methods
- __construct() : mixed
- Will attempt to get environment variables with names that match the properties of the child class.
- __set_state() : mixed
- getEnvValue() : string|null
- Retrieve an environment-specific configuration setting
- initEnvValue() : void
- Initialization an environment-specific configuration setting
- registerProperties() : void
- Provides external libraries a simple way to register one or more options into a config file.
Properties
$aliases
Configures aliases for Filter classes to make reading things nicer and simpler.
public
array<string, class-string|array<int, class-string>>
$aliases
= ['csrf' => \CodeIgniter\Filters\CSRF::class, 'toolbar' => \CodeIgniter\Filters\DebugToolbar::class, 'honeypot' => \CodeIgniter\Filters\Honeypot::class, 'invalidchars' => \CodeIgniter\Filters\InvalidChars::class, 'secureheaders' => \CodeIgniter\Filters\SecureHeaders::class, 'cors' => \CodeIgniter\Filters\Cors::class, 'forcehttps' => \CodeIgniter\Filters\ForceHTTPS::class, 'pagecache' => \CodeIgniter\Filters\PageCache::class, 'performance' => \CodeIgniter\Filters\PerformanceMetrics::class]
[filter_name => classname] or [filter_name => [classname1, classname2, ...]]
$filters
List of filter aliases that should run on any before or after URI patterns.
public
array<string|int, mixed>
$filters
= []
Example: 'isLoggedIn' => ['before' => ['account/', 'profiles/']]
$globals
List of filter aliases that are always applied before and after every request.
public
array<string, array<string, array<string, string>>>|array<string, array<int, string>>
$globals
= ['before' => [], 'after' => []]
$methods
List of filter aliases that works on a particular HTTP method (GET, POST, etc.).
public
array<string, array<int, string>>
$methods
= []
Example: 'POST' => ['foo', 'bar']
If you use this, you should disable auto-routing because auto-routing permits any HTTP method to access a controller. Accessing the controller with a method you don't expect could bypass the filter.
$override
Whether to override properties by Env vars and Registrars.
public
static bool
$override
= true
$registrars
An optional array of classes that will act as Registrars for rapidly setting config class properties.
public
static array<string|int, mixed>
$registrars
= []
$required
List of special required filters.
public
array{before: list, after: list}
$required
= ['before' => [
'forcehttps',
// Force Global Secure Requests
'pagecache',
], 'after' => [
'pagecache',
// Web Page Caching
'performance',
// Performance Metrics
'toolbar',
]]
The filters listed here are special. They are applied before and after other kinds of filters, and always applied even if a route does not exist.
Filters set by default provide framework functionality. If removed, those functions will no longer work.
Tags
$didDiscovery
Has module discovery happened yet?
protected
static bool
$didDiscovery
= false
$moduleConfig
The modules configuration.
protected
static Modules|null
$moduleConfig
Methods
__construct()
Will attempt to get environment variables with names that match the properties of the child class.
public
__construct() : mixed
The "shortPrefix" is the lowercase-only config class name.
__set_state()
public
static __set_state(array<string|int, mixed> $array) : mixed
Parameters
- $array : array<string|int, mixed>
getEnvValue()
Retrieve an environment-specific configuration setting
protected
getEnvValue(string $property, string $prefix, string $shortPrefix) : string|null
Parameters
- $property : string
- $prefix : string
- $shortPrefix : string
Return values
string|nullinitEnvValue()
Initialization an environment-specific configuration setting
protected
initEnvValue(array<string|int, mixed>|bool|float|int|string|null &$property, string $name, string $prefix, string $shortPrefix) : void
Parameters
- $property : array<string|int, mixed>|bool|float|int|string|null
- $name : string
- $prefix : string
- $shortPrefix : string
registerProperties()
Provides external libraries a simple way to register one or more options into a config file.
protected
registerProperties() : void