protected function resolvePrivileges($permissions, $action, Resource $resource)
    {
        // Search for privileges in the permissions.
        foreach ($permissions as $permission) {
            // If we've found a valid privilege, return true.
            if ($permission instanceof Privilege && $permission->isAllowed($this, $action, $resource)) {
                return true;
            }
        }

        return false;
    }