public function isActionAllowed(array $rights, $controller, $action, $index = '', $collection = '')
    {
        // We filter in all the rights that match the request (including wildcards).
        $filteredRights = array_filter($rights, function (array $right) use ($controller) {
            return array_key_exists('controller', $right) && ($right['controller'] === $controller || $right['controller'] === '*');
        });

        $filteredRights = array_filter($filteredRights, function (array $right) use ($action) {
            return array_key_exists('action', $right) && ($right['action'] === $action || $right['action'] === '*');
        });

        $filteredRights = array_filter($filteredRights, function (array $right) use ($index) {
            return array_key_exists('index', $right) && ($right['index'] === $index || $right['index'] === '*');
        });

        $filteredRights = array_filter($filteredRights, function (array $right) use ($collection) {
            return array_key_exists('collection', $right) && ($right['collection'] === $collection || $right['collection'] === '*');
        });

        $rightsValues = array_map(function ($element) {
            return $element['value'];
        }, $filteredRights);

        // Then, if at least one right allows the action, we return Security::ACTION_ALLOWED
        if (array_search(Security::ACTION_ALLOWED, $rightsValues) !== false) {
            return Security::ACTION_ALLOWED;
        } // If no right allows the action, we check for Security::ACTION_CONDITIONAL.
        elseif (array_search(Security::ACTION_CONDITIONAL, $rightsValues) !== false) {
            return Security::ACTION_CONDITIONAL;
        }

        // Otherwise we return Security::ACTION_DENIED.
        return Security::ACTION_DENIED;
    }