Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. QueryParameterRequestMatcher.php

class QueryParameterRequestMatcher

Checks the presence of HTTP query parameters of a Request.

@author Alexandre Daubois <alex.daubois@gmail.com>

Hierarchy

  • class \Symfony\Component\HttpFoundation\RequestMatcher\QueryParameterRequestMatcher implements \Symfony\Component\HttpFoundation\RequestMatcherInterface

Expanded class hierarchy of QueryParameterRequestMatcher

File

vendor/symfony/http-foundation/RequestMatcher/QueryParameterRequestMatcher.php, line 22

Namespace

Symfony\Component\HttpFoundation\RequestMatcher
View source
class QueryParameterRequestMatcher implements RequestMatcherInterface {
    
    /**
     * @var string[]
     */
    private array $parameters;
    
    /**
     * @param string[]|string $parameters A parameter or a list of parameters
     *                                    Strings can contain a comma-delimited list of query parameters
     */
    public function __construct(array|string $parameters) {
        $this->parameters = array_reduce(array_map(strtolower(...), (array) $parameters), static fn(array $parameters, string $parameter) => array_merge($parameters, preg_split('/\\s*,\\s*/', $parameter)), []);
    }
    public function matches(Request $request) : bool {
        if (!$this->parameters) {
            return true;
        }
        return 0 === \count(array_diff_assoc($this->parameters, $request->query
            ->keys()));
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
QueryParameterRequestMatcher::$parameters private property
QueryParameterRequestMatcher::matches public function Decides whether the rule(s) implemented by the strategy matches the supplied request. Overrides RequestMatcherInterface::matches
QueryParameterRequestMatcher::__construct public function

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal