Deleting permission with and remove it from role_permission connection

@param string $action
@throws \Exception
506755
public function deletePermission(string $action): void
    {
        /** @var HCAclPermission $permission */
        $permission = $this->findOneBy(['action' => $action]);

        $permission->roles()->detach();

        $permission->forceDelete();
    }
1247881
private function executeAction(string $action)
    {
        list($controller, $method) = explode('@', $action);

        $class = '\App\Controllers\\'.ucfirst($controller).'Controller';

        if (!class_exists($class)) {
            throw new ExceptionHandler('Class "'.$class.'" not found.');
        }

        $controllerInstantiate = new $class();

        if (!method_exists($controllerInstantiate, $method)) {
            throw new ExceptionHandler('Method "'.$method.'" not found in '.$class.'.');
        }

        return call_user_func_array([new $controllerInstantiate, $method], []);
    }
982575
public function clear($action = null, $resource = null, $resourceId = null)
    {
        $actions = (array) $action;
        $resourceObject = $this->convertResourceToObject($resource, $resourceId);
        $permissions = $this->getPermissions();

        if ($action === null && $resource === null) {
            // Clear every permission for this lock instance.
            foreach ($permissions as $permission) {
                $this->removePermission($permission);
            }
        } elseif ($action === null && $resource !== null) {
            // Clear all permissions for a given resource.
            /** @todo Needs to be implemented */
        } else {
            // Clear every permission for the given actions.
            foreach ($actions as $action) {
                $this->clearPermission($action, $resourceObject, $permissions);
            }
        }
    }
863483
protected function executePhpAction(Config\Action $action) : void
    {
        $this->beforeAction();
        $runner = new Action\PHP();
        $runner->execute($this->config, $this->io, $this->repository, $action);
        $this->afterAction();
    }
980252
def remove_user_permission(rid, uid, action='full'):
    
    rid = rid.replace('/', '%252F')

    try:
        acl_url = urljoin(_acl_url(), 'acls/{}/users/{}/{}'.format(rid, uid, action))
        r = http.delete(acl_url)
        assert r.status_code == 204
    except DCOSHTTPException as e:
        if e.response.status_code != 400:
            raise
1344788
public function grantRoleAccess(RoleInterface $role, ResourceInterface $resource, string $action)
    {
        $resourcePermissions = $this->getGroupPermissions($resource);
        $matchedPermission = null;

        //
        // 1. Check to see if the role, or its parents already have access.  Don't pollute the database.
        //
        $examinedRole = $role;
        while ($examinedRole) {
            foreach ($resourcePermissions as $permission) {
                if ($role === $permission->getRole()) {
                    $matchedPermission = $permission;
                }

                if ($permission->can($action)) {
                    throw new ExistingAccessException($role, $resource, $action, $permission->getRole()->getName());
                }
            }
            $examinedRole = $examinedRole->getParent();
        }

        //
        // 2. Give access
        //
        if (!$matchedPermission) {
            $newPermission = $this->groupPermissions->create($role, $resource->getClass(), $resource->getId(), [$action]);
            $this->groupPermissions->save($newPermission);
        } else {
            $matchedPermission->addAction($action);
            $this->groupPermissions->update($matchedPermission);

        }
    }
1195737
protected function perform($action)
    {
        $this->plugin->io->writeError('running ' . $this->getBin());
        if ($this->passthru([$action])) {
            $this->plugin->io->writeError('<error>failed ' . $this->name . ' ' . $action . '</error>');
        }
    }
132081
public function beforeAction($action)
    {
        if (!$this->enableDebugLogs) {
            foreach ($this->get('log')->targets as $target) {
                $target->enabled = false;
            }
        }

        if (!parent::beforeAction($action)) {
            return false;
        }

        // do not display debug toolbar when in debug view mode
        Yii::$app->getView()->off(View::EVENT_END_BODY, [$this, 'renderToolbar']);
        Yii::$app->getResponse()->off(Response::EVENT_AFTER_PREPARE, [$this, 'setDebugHeaders']);

        if ($this->checkAccess($action)) {
            $this->resetGlobalSettings();
            return true;
        }

        if ($action->id === 'toolbar') {
            // Accessing toolbar remotely is normal. Do not throw exception.
            return false;
        }

        throw new ForbiddenHttpException('You are not allowed to access this page.');
    }
730973
public function editImage($action)
    {
        $image = $this->loadImage();

        $path = $this->processImage($action, $image);

        $this->changeImagePath($path);
    }
814227
public function checkAccessAction($action)
    {
        $actionOrigCasing = $action;
        $action = strtolower($action);

        $isAllowed = false;
        $isDefined = false;

        // Get actions for this specific class (without inheritance)
        $definingClass = $this->definingClassForAction($actionOrigCasing);
        $allowedActions = $this->allowedActions($definingClass);

        // check if specific action is set
        if (isset($allowedActions[$action])) {
            $isDefined = true;
            $test = $allowedActions[$action];
            if ($test === true || $test === 1 || $test === '1') {
                // TRUE should always allow access
                $isAllowed = true;
            } elseif (substr($test, 0, 2) == '->') {
                // Determined by custom method with "->" prefix
                list($method, $arguments) = ClassInfo::parse_class_spec(substr($test, 2));
                $isAllowed = call_user_func_array([$this, $method], $arguments);
            } else {
                // Value is a permission code to check the current member against
                $isAllowed = Permission::check($test);
            }
        } elseif (is_array($allowedActions)
            && (($key = array_search($action, $allowedActions, true)) !== false)
            && is_numeric($key)
        ) {
            // Allow numeric array notation (search for array value as action instead of key)
            $isDefined = true;
            $isAllowed = true;
        } elseif (is_array($allowedActions) && !count($allowedActions)) {
            // If defined as empty array, deny action
            $isAllowed = false;
        } elseif ($allowedActions === null) {
            // If undefined, allow action based on configuration
            $isAllowed = false;
        }

        // If we don't have a match in allowed_actions,
        // whitelist the 'index' action as well as undefined actions based on configuration.
        if (!$isDefined && ($action == 'index' || empty($action))) {
            $isAllowed = true;
        }

        return $isAllowed;
    }
793503
public function setAction(string $action)
    {
        $string = new CamelCase($action);
        $this->action = $string->camelize();
    }
120536
protected function checkPermissions($key, $action)
    {
        if (!($action & $this->options)) {
            $originalKey = is_null($this->key) ? $key : $this->key;
            $this->key = null;
            $text = Friendlification::getConstNameByValue(
                __CLASS__, $action
            );
            throw new RuntimeException(
                is_null($key)
                    ? sprintf("%s: no permissions", $text)
                    : sprintf(
                        "%s: no permissions for key '%s'", $text,
                        $originalKey
                    ),
                $action
            );
        }
    }
1370841
public static function permissionDelete($name, $action): void
    {
        $permission = HCAclPermission::where('name', $name)
            ->where('action', $action)
            ->first();

        if (!is_null($permission)) {
            RolesPermissionsConnections::where('permission_id', $permission->id)->delete();

            $permission->forceDelete();
        }
    }
224226
public function deleteAction(Asset $asset): void
    {
        $usageReferences = $this->assetService->getUsageReferences($asset);
        if (count($usageReferences) > 0) {
            $this->addFlashMessage('deleteRelatedNodes', '', Message::SEVERITY_WARNING, [], 1412422767);
            $this->redirect('index');
        }

        $this->assetRepository->remove($asset);
        $this->addFlashMessage('assetHasBeenDeleted', '', Message::SEVERITY_OK, [$asset->getLabel()], 1412375050);
        $this->redirect('index');
    }
870263
protected function setPermissions($permissions)
    {
        foreach ($permissions as $action => $permission) {
            $this->setPermission($action, $permission);
        }
    }
39669
protected function resolvePermissions($action, Resource $resource)
    {
        $permissions = $this->getPermissions();

        // Search for restrictions in the permissions. We'll do this first
        // because restrictions should override any privileges.
        if (! $this->resolveRestrictions($permissions, $action, $resource)) {
            return false;
        }

        // Check if one of the caller's roles has permission to do the action on the resource.
        foreach ($this->getLockInstancesForCallerRoles() as $roleLock) {
            if ($roleLock->can($action, $resource)) {
                return true;
            }
        }

        // If no restrictions are found, pass when a privilege is found on either the roles or caller.
        return $this->resolvePrivileges($permissions, $action, $resource);
    }
943301
protected function authorizationFailedError($resource, $action) {
    // when reading only log the error to avoid errors on the display
    $msg = ObjectFactory::getInstance('message')->
            getText("Authorization failed for action '%0%' on '%1%'.", [$action, $resource]);
    if ($action == PersistenceAction::READ) {
      self::$logger->error($msg."\n".ErrorHandler::getStackTrace());
    }
    else {
      throw new AuthorizationException($msg);
    }
  }