Beispiel #1
0
 protected function handleAnnotation($value, RouterEvent $event)
 {
     $request = $event->getRequest();
     if (!$request->isSecure() && $value) {
         $url = str_replace('http', 'https', $request->getSchemeAndHttpHost()) . $request->getRequestUri();
         $event->setResponse(new RedirectResponse($url, 301));
     }
 }
Beispiel #2
0
 protected function handleAnnotation($value, RouterEvent $event)
 {
     if ($value) {
         if (is_bool($value)) {
             throw new \InvalidArgumentException('You must specify which HTTP method(s) you require.');
         }
         if (is_string($value)) {
             $value = [$value];
         }
         $value = array_map('strtoupper', $value);
         if (!in_array($event->getRequest()->getMethod(), $value)) {
             $event->setResponse(new Response('Invalid http method', 400));
         }
     }
 }