Dissociates an ability from several resource nodes.

@param Ability $ability
@param array   $nodes

@return string
547312
public function dissociateAbilityFromResources(Ability $ability, array $nodes)
    {
        foreach ($nodes as $node) {
            $ability->removeResource($node);
        }
        $this->om->persist($ability);
        $this->om->flush();
    }
260139
public static void recycleNodes(Collection<AccessibilityNodeInfoCompat> nodes) {
        if (nodes == null) {
            return;
        }

        for (AccessibilityNodeInfoCompat node : nodes) {
            if (node != null) {
                node.recycle();
            }
        }

        nodes.clear();
    }
457025
protected function getAssociatedAbilityIds($authority, array $abilityIds, $forbidden)
    {
        if (is_null($authority)) {
            return $this->getAbilityIdsAssociatedWithEveryone($abilityIds, $forbidden);
        }

        $relation = $authority->abilities();

        $table = Models::table('abilities');

        $relation->whereIn("{$table}.id", $abilityIds)
                 ->wherePivot('forbidden', '=', $forbidden);

        Models::scope()->applyToRelation($relation);

        return $relation->get(["{$table}.id"])->pluck('id')->all();
    }
256196
public function can($ability, $arguments = [])
    {
        foreach ($this->abilities as $check) {
            if (fnmatch($check, $ability)) {
                return true;
            }
        }

        return false;
    }
110349
public function revoke($ability) {
    if (in_array($ability, $this->abilities)) {
      return $this->abilities =
        array_values(array_diff($this->abilities, [$ability]));
    }
    return true;
  }
725242
public function can($ability, $arguments = [])
    {
        return app(Gate::class)->forUser($this)->check($ability, $arguments);
    }
1367904
public function has($ability)
    {
        $abilities = is_array($ability) ? $ability : func_get_args();

        foreach ($abilities as $ability) {
            if (! isset($this->abilities[$ability])) {
                return false;
            }
        }

        return true;
    }
32589
public function allows($ability, $arguments = [])
    {
        if (!is_array($arguments)) {
            $arguments = [ $arguments ];
        }

        array_unshift($arguments, $ability);
        return call_user_func_array([ $this->gatekeeper, 'allows'], $arguments);
    }
593719
protected function disassociateEveryone(array $ids)
    {
        $query = Models::query('permissions')
            ->whereNull('entity_id')
            ->where($this->constraints())
            ->whereIn('ability_id', $ids);

        Models::scope()->applyToRelationQuery($query, $query->from);

        $query->delete();
    }
648271
public function authorize($ability, $arguments = array())
    {
        list($ability, $arguments) = $this->parseAbilityAndArguments($ability, $arguments);

        $gate = App::make('Nova\Auth\Access\GateInterface');

        return $this->authorizeAtGate($gate, $ability, $arguments);
    }
621658
public function can($ability, $arguments = []) : bool
    {
        if ($this->isAdministrator()) {
            return true;
        }

        if ($this->permissions->pluck('slug')->contains($ability)) {
            return true;
        }

        return $this->roles->pluck('permissions')->flatten()->pluck('slug')->contains($ability);
    }
237478
protected function checkGrammar(array $nodes)
    {
        // TODO Make sure that separators are only in the child nodes of the array node of a function node
        // (If this happens the calculator will throw an exception)

        foreach ($nodes as $index => $node) {
            if (is_a($node, SymbolNode::class)) {
                /** @var $node SymbolNode */

                $symbol = $node->getSymbol();

                if (is_a($symbol, AbstractOperator::class)) {
                    /** @var $symbol AbstractOperator */

                    $posOfRightOperand = $index + 1;

                    // Make sure the operator is positioned left of a (potential) operand (=prefix notation).
                    // Example term: "-1"
                    if ($posOfRightOperand >= sizeof($nodes)) {
                        $this->throwException(
                            ParserException::class,
                            'Error: Found operator that does not stand before an operand.',
                            $node->getToken()->getValue(),
                            $node->getToken()->getPosition()
                        );
                    }

                    $posOfLeftOperand = $index - 1;

                    $leftOperand = null;

                    // Operator is unary if positioned at the beginning of a term
                    if ($posOfLeftOperand >= 0) {
                        $leftOperand = $nodes[$posOfLeftOperand];

                        if (is_a($leftOperand, SymbolNode::class)) {
                            /** @var $leftOperand SymbolNode */
                            if (is_a($leftOperand->getSymbol(), AbstractOperator::class)
                                ||
                                is_a($leftOperand->getSymbol(), AbstractSeparator::class)
                            ) {
                                // Operator is unary if positioned right to another operator
                                $leftOperand = null;
                            }
                        }
                    }

                    // If null, the operator is unary
                    if ($leftOperand === null) {
                        if (! $symbol->getOperatesUnary()) {
                            $this->throwException(
                                ParserException::class,
                                'Error: Found operator in unary notation that is not unary.',
                                $node->getToken()->getValue(),
                                $node->getToken()->getPosition()
                            );
                        }

                        // Remember that this node represents a unary operator
                        $node->setIsUnaryOperator(true);
                    } else {
                        if (! $symbol->getOperatesBinary()) {
                            $this->throwException(
                                ParserException::class,
                                'Error: Found operator in binary notation that is not binary.',
                                $node->getToken()->getValue(),
                                $node->getToken()->getPosition()
                            );
                        }
                    }
                }
            } else {
                /** @var $node ContainerNode */
                $this->checkGrammar($node->getChildNodes());
            }
        }

        if ($this->customGrammarChecker !== null) {
            $customGrammarChecker = $this->customGrammarChecker;

            // Execute custom grammar checker function
            $customGrammarChecker($nodes);
        }
    }
1306283
public function transform(Ability $ability)
    {
        return [
            'actions' => $ability->actions,
            'conditions' => $ability->conditions,
            'id' => $ability->id,
            'subject' => $ability->subject,
        ];
    }
865670
public function can($ability, $arguments = array())
    {
        $gate = App::make('Nova\Auth\Access\GateInterface')->forUser($this);

        return $gate->check($ability, $arguments);
    }
460780
public function dissociateCompetencyFromResources(Competency $competency, array $nodes)
    {
        foreach ($nodes as $node) {
            $competency->removeResource($node);
        }
        $this->om->persist($competency);
        $this->om->flush();
    }
475233
public function associateCompetencyToResources(Competency $competency, array $nodes)
    {
        $associatedNodes = [];

        foreach ($nodes as $node) {
            if (!$competency->isLinkedToResource($node)) {
                $competency->linkResource($node);
                $associatedNodes[] = $node;
            }
        }
        $this->om->persist($competency);
        $this->om->flush();

        return $associatedNodes;
    }
444793
protected function getModelAbility($ability, $entity, array $attributes)
    {
        $entity = $this->getEntityInstance($entity);

        $existing = $this->findAbility($ability, $entity, $attributes);

        return $existing ?: $this->createAbility($ability, $entity, $attributes);
    }