Neos\Flow\Security\RequestPattern\ControllerObjectName::matchRequest PHP Метод

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

Matches a \Neos\Flow\Mvc\RequestInterface against its set controller object name pattern rules
public matchRequest ( Neos\Flow\Mvc\RequestInterface $request ) : boolean
$request Neos\Flow\Mvc\RequestInterface The request that should be matched
Результат boolean TRUE if the pattern matched, FALSE otherwise
    public function matchRequest(RequestInterface $request)
    {
        if (!isset($this->options['controllerObjectNamePattern'])) {
            throw new InvalidRequestPatternException('Missing option "controllerObjectNamePattern" in the ControllerObjectName request pattern configuration', 1446224501);
        }
        return (bool) preg_match('/^' . str_replace('\\', '\\\\', $this->options['controllerObjectNamePattern']) . '$/', $request->getControllerObjectName());
    }

Usage Example

 /**
  * @test
  */
 public function matchRequestReturnsFalseIfTheCurrentRequestDoesNotMatchTheControllerObjectNamePattern()
 {
     $request = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->setMethods(['getControllerObjectName'])->getMock();
     $request->expects($this->once())->method('getControllerObjectName')->will($this->returnValue('Some\\Package\\Controller\\SomeController'));
     $requestPattern = new ControllerObjectName(['controllerObjectNamePattern' => 'Neos\\Flow\\Security\\.*']);
     $this->assertFalse($requestPattern->matchRequest($request));
 }