public function setRules(array $rules)
    {
        $this->rules = [];

        foreach ($rules as $rule) {
            $controller  = strtolower($rule['controller']);
            $actions     = isset($rule['actions']) ? (array)$rule['actions'] : [];
            $permissions = (array)$rule['permissions'];

            if (empty($actions)) {
                $this->rules[$controller][0] = $permissions;
                continue;
            }

            foreach ($actions as $action) {
                $this->rules[$controller][strtolower($action)] = $permissions;
            }
        }
    }
public function setRules(array $rules)
    {
        $this->rules = [];

        foreach ($rules as $rule) {
            $controller  = strtolower($rule['controller']);
            $actions     = isset($rule['actions']) ? (array)$rule['actions'] : [];
            $permissions = (array)$rule['permissions'];

            if (empty($actions)) {
                $this->rules[$controller][0] = $permissions;
                continue;
            }

            foreach ($actions as $action) {
                $this->rules[$controller][strtolower($action)] = $permissions;
            }
        }
    }
public function setRules ( array $ rules ) { $ this -> rules = [ ] ; foreach ( $ rules as $ rule ) { $ controller = strtolower ( $ rule [ 'controller' ] ) ; $ actions = isset ( $ rule [ 'actions' ] ) ? ( array ) $ rule [ 'actions' ] : [ ] ; $ permissions = ( array ) $ rule [ 'permissions' ] ; if ( empty ( $ actions ) ) { $ this -> rules [ $ controller ] [ 0 ] = $ permissions ; continue ; } foreach ( $ actions as $ action ) { $ this -> rules [ $ controller ] [ strtolower ( $ action ) ] = $ permissions ; } } }
Set the rules

A controller rule is made the following way:

[
'controller' => 'ControllerName',
'actions'    => []/string
'roles'      => []/string
]

@param  array $rules
@return void
Set the rules