public matchRequest ( Neos\Flow\Mvc\RequestInterface $request ) : boolean | ||
$request | Neos\Flow\Mvc\RequestInterface | The request that should be matched |
return | 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());
}
/** * @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)); }