Mecha CMS

Code snippet collection for developers.

State Hooks

Force some values to the default states values.

There will be a time when you want to force some configuration data of the extension and plugin to be specific to your custom shield. Here is an example on how to force the comment captcha type to text with black background and blue color using a hook:

Hook::set('plugin.state.comment-captcha', function($lot) {
    $lot['type'] = 'text';
    $lot['types']['text'][0] = '000';
    $lot['types']['text'][1] = '00f';
    return $lot;

Example for extension:

Hook::set('extend.state.minify', function($lot) { … });

Example for shield:

Hook::set('shield.state.document', function($lot) { … });