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

Breadcrumb

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

class MethodRequestMatcher

Checks the HTTP method of a Request.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

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

Expanded class hierarchy of MethodRequestMatcher

File

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

Namespace

Symfony\Component\HttpFoundation\RequestMatcher
View source
class MethodRequestMatcher implements RequestMatcherInterface {
    
    /**
     * @var string[]
     */
    private array $methods = [];
    
    /**
     * @param string[]|string $methods An HTTP method or an array of HTTP methods
     *                                 Strings can contain a comma-delimited list of methods
     */
    public function __construct(array|string $methods) {
        $this->methods = array_reduce(array_map('strtoupper', (array) $methods), static fn(array $methods, string $method) => array_merge($methods, preg_split('/\\s*,\\s*/', $method)), []);
    }
    public function matches(Request $request) : bool {
        if (!$this->methods) {
            return true;
        }
        return \in_array($request->getMethod(), $this->methods, true);
    }

}

Members

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

API Navigation

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