Sets the runtime default locale for the request based on the Accept-Language header. The default will only be set if it matches the list of passed valid locales.
__construct( array $config [] )
Constructor.
$config
optional [] Cake\Core\Exception\Exception
Cake\Routing\DispatcherFilter::__construct()
beforeDispatch( Cake\Event\Event $event )
Inspects the request for the Accept-Language header and sets the Locale for the current runtime if it matches the list of valid locales as passed in the configuration.
Cake\Event\Event
$event
Cake\Routing\DispatcherFilter::beforeDispatch()
afterDispatch( Cake\Event\Event $event )
Method called after the controller served a request and generated a response. It is possible to alter the response object at this point as it is not sent to the client yet.
If false is returned, the event will be stopped and no more listeners will be notified. Alternatively you can call $event->stopPropagation()
to achieve the same result.
Cake\Event\Event
$event
request
and response
keys in the data property.handle( Cake\Event\Event $event )
Handler method that applies conditions and resolves the correct method to call.
Cake\Event\Event
$event
mixed
implementedEvents( )
Returns the list of events this filter listens to. Dispatcher notifies 2 different events Dispatcher.before
and Dispatcher.after
. By default this class will attach preDispatch
and postDispatch
method respectively.
Override this method at will to only listen to the events you are interested in.
array
Cake\Event\EventListenerInterface::implementedEvents()
matches( Cake\Event\Event $event )
Check to see if the incoming request matches this filter's criteria.
Cake\Event\Event
$event
boolean
_configDelete( string $key )
Delete a single config key
$key
Cake\Core\Exception\Exception
_configRead( string|null $key )
Read a config variable
$key
mixed
_configWrite( string|array $key , mixed $value , boolean|string $merge false )
Write a config variable
$key
$value
$merge
optional false Cake\Core\Exception\Exception
config( string|array|null $key null , mixed|null $value null , boolean $merge true )
Reading the whole config:
$this->config();
Reading a specific value:
$this->config('key');
Reading a nested value:
$this->config('some.nested.key');
Setting a specific value:
$this->config('key', $value);
Setting a nested value:
$this->config('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->config(['one' => 'value', 'another' => 'value']);
$key
optional null $value
optional null $merge
optional true mixed
Cake\Core\Exception\Exception
configShallow( string|array $key , mixed|null $value null )
Merge provided config with existing config. Unlike config()
which does a recursive merge for nested keys, this method does a simple merge.
Setting a specific value:
$this->config('key', $value);
Setting a nested value:
$this->config('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->config(['one' => 'value', 'another' => 'value']);
$key
$value
optional null mixed
protected array
Default config
These are merged with user-provided config when the class is used. The when and for options allow you to define conditions that are checked before your filter is called.
[ 'when' => null, 'for' => null, 'priority' => null, ]
protected boolean
Whether the config property has already been configured with defaults
false
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/3.1/class-Cake.Routing.Filter.LocaleSelectorFilter.html