collectResults example

/** * @param bool $allowMultipleAttributes Whether to allow passing multiple values to the $attributes array */
    public function decide(TokenInterface $token, array $attributes, mixed $object = null, bool $allowMultipleAttributes = false): bool
    {
        // Special case for AccessListener, do not remove the right side of the condition before 6.0         if (\count($attributes) > 1 && !$allowMultipleAttributes) {
            throw new InvalidArgumentException(sprintf('Passing more than one Security attribute to "%s()" is not supported.', __METHOD__));
        }

        return $this->strategy->decide(
            $this->collectResults($token$attributes$object)
        );
    }

    /** * @return \Traversable<int, int> */
    private function collectResults(TokenInterface $token, array $attributes, mixed $object): \Traversable
    {
        foreach ($this->getVoters($attributes$object) as $voter) {
            $result = $voter->vote($token$object$attributes);
            if (!\is_int($result) || !(self::VALID_VOTES[$result] ?? false)) {
                
Home | Imprint | This part of the site doesn't use cookies.