Sulu\Component\Webspace\Analyzer\RequestAnalyzerInterface::validate PHP Method

validate() public method

Validates the data written on the given request and throws exceptions in case something is wrong or missing.
public validate ( Request $request )
$request Symfony\Component\HttpFoundation\Request
    public function validate(Request $request);

Usage Example

Example #1
0
 /**
  * Analyzes the request before passing the event to the default RouterListener from symfony and validates the result
  * afterwards.
  *
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     // This call is required in all cases, because the default router needs our webspace information
     // Would be nice to also only call this if the _requestAnalyzer attribute is set, but it's set on the next line
     $this->requestAnalyzer->analyze($request);
     $this->baseRouteListener->onKernelRequest($event);
     if ($request->attributes->get(static::REQUEST_ANALYZER, true) !== false) {
         $this->requestAnalyzer->validate($request);
     }
 }