Neos\Flow\Aop\Pointcut\PointcutFilterComposite::matches PHP Метод

matches() публичный Метод

Checks if the specified class and method match the registered class- and method filter patterns.
public matches ( string $className, string $methodName, string $methodDeclaringClassName, mixed $pointcutQueryIdentifier ) : boolean
$className string Name of the class to check against
$methodName string Name of the method to check against
$methodDeclaringClassName string Name of the class the method was originally declared in
$pointcutQueryIdentifier mixed Some identifier for this query - must at least differ from a previous identifier. Used for circular reference detection.
Результат boolean TRUE if class and method match the pattern, otherwise FALSE
    public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier)
    {
        $this->runtimeEvaluationsDefinition = [];
        $matches = true;
        foreach ($this->filters as &$operatorAndFilter) {
            list($operator, $filter) = $operatorAndFilter;
            $currentFilterMatches = $filter->matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier);
            $currentRuntimeEvaluationsDefinition = $filter->getRuntimeEvaluationsDefinition();
            switch ($operator) {
                case '&&':
                    if ($currentFilterMatches === true && $filter->hasRuntimeEvaluationsDefinition()) {
                        if (!isset($this->runtimeEvaluationsDefinition[$operator])) {
                            $this->runtimeEvaluationsDefinition[$operator] = [];
                        }
                        $this->runtimeEvaluationsDefinition[$operator] = array_merge_recursive($this->runtimeEvaluationsDefinition[$operator], $currentRuntimeEvaluationsDefinition);
                    }
                    if ($this->earlyReturn && !$currentFilterMatches) {
                        return false;
                    }
                    $matches = $matches && $currentFilterMatches;
                    break;
                case '&&!':
                    if ($currentFilterMatches === true && $filter->hasRuntimeEvaluationsDefinition()) {
                        if (!isset($this->runtimeEvaluationsDefinition[$operator])) {
                            $this->runtimeEvaluationsDefinition[$operator] = [];
                        }
                        $this->runtimeEvaluationsDefinition[$operator] = array_merge_recursive($this->runtimeEvaluationsDefinition[$operator], $currentRuntimeEvaluationsDefinition);
                        $currentFilterMatches = false;
                    }
                    if ($this->earlyReturn && $currentFilterMatches) {
                        return false;
                    }
                    $matches = $matches && !$currentFilterMatches;
                    break;
                case '||':
                    if ($currentFilterMatches === true && $filter->hasRuntimeEvaluationsDefinition()) {
                        if (!isset($this->runtimeEvaluationsDefinition[$operator])) {
                            $this->runtimeEvaluationsDefinition[$operator] = [];
                        }
                        $this->runtimeEvaluationsDefinition[$operator] = array_merge_recursive($this->runtimeEvaluationsDefinition[$operator], $currentRuntimeEvaluationsDefinition);
                    }
                    $matches = $matches || $currentFilterMatches;
                    break;
                case '||!':
                    if ($currentFilterMatches === true && $filter->hasRuntimeEvaluationsDefinition()) {
                        if (!isset($this->runtimeEvaluationsDefinition[$operator])) {
                            $this->runtimeEvaluationsDefinition[$operator] = [];
                        }
                        $this->runtimeEvaluationsDefinition[$operator] = array_merge_recursive($this->runtimeEvaluationsDefinition[$operator], $currentRuntimeEvaluationsDefinition);
                        $currentFilterMatches = false;
                    }
                    $matches = $matches || !$currentFilterMatches;
                    break;
            }
        }
        return $matches;
    }

Usage Example

Пример #1
0
 /**
  * Checks if the given class and method match this pointcut.
  * Before each match run, reset() must be called to reset the circular references guard.
  *
  * @param string $className Class to check against
  * @param string $methodName Method to check against
  * @param string $methodDeclaringClassName Name of the class the method was originally declared in
  * @param mixed $pointcutQueryIdentifier Some identifier for this query - must at least differ from a previous identifier. Used for circular reference detection.
  * @return boolean TRUE if class and method match this point cut, otherwise FALSE
  * @throws CircularPointcutReferenceException if a circular pointcut reference was detected
  */
 public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier)
 {
     if ($this->pointcutQueryIdentifier === $pointcutQueryIdentifier) {
         $this->recursionLevel++;
         if ($this->recursionLevel > self::MAXIMUM_RECURSIONS) {
             throw new CircularPointcutReferenceException('Circular pointcut reference detected in ' . $this->aspectClassName . '->' . $this->pointcutMethodName . ', too many recursions (Query identifier: ' . $pointcutQueryIdentifier . ').', 1172416172);
         }
     } else {
         $this->pointcutQueryIdentifier = $pointcutQueryIdentifier;
         $this->recursionLevel = 0;
     }
     return $this->pointcutFilterComposite->matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier);
 }
All Usage Examples Of Neos\Flow\Aop\Pointcut\PointcutFilterComposite::matches