/**
  * {@inheritdoc}
  */
 protected function processConsentScreen(AuthorizationInterface $authorization, ServerRequestInterface $request, ResponseInterface &$response)
 {
     $options = $this->processConsentScreenOptions($authorization);
     $ui_locale = $this->getUiLocale($authorization);
     $options = array_merge($options, ['locale' => $ui_locale, 'scopes' => $authorization->getScopes(), 'allow_scope_selection' => $this->allow_scope_selection]);
     $authorization_model = new AuthorizationModel();
     $authorization_model->setScopes($authorization->getScopes());
     $form = $this->form_factory->createForm($options, $authorization_model);
     if ('POST' === $request->getMethod()) {
         $this->event_dispatcher->dispatch(Events::OAUTH2_PRE_AUTHORIZATION, new PreAuthorizationEvent($authorization));
         $result = $this->form_handler->handle($form, $request, $authorization, $authorization_model);
         if (true === $result) {
             $this->processAuthorization($request, $response, $authorization);
             $this->event_dispatcher->dispatch(Events::OAUTH2_POST_AUTHORIZATION, new PostAuthorizationEvent($authorization));
             return ['save_authorization' => $authorization_model->isSaveConfiguration()];
         }
     }
     $this->prepareResponse($authorization, $response, $form, $ui_locale);
 }
 public function authorizationAction(ServerRequestInterface $request)
 {
     $response = new Response();
     try {
         $authorization = $this->createAuthorization($request);
         if (null !== $this->event_dispatcher) {
             $this->event_dispatcher->dispatch(Events::OAUTH2_PRE_AUTHORIZATION, new PreAuthorizationEvent($authorization));
         }
         $this->form->setData($authorization);
         if ('POST' === $request->getMethod()) {
             $this->form_handler->handle($this->form, $request, $response, $authorization);
             if (null !== $this->event_dispatcher) {
                 $this->event_dispatcher->dispatch(Events::OAUTH2_POST_AUTHORIZATION, new PostAuthorizationEvent($authorization));
             }
             return $response;
         }
     } catch (BaseExceptionInterface $e) {
         $e->getHttpResponse($response);
         return $response;
     }
     $this->prepareResponse($authorization, $response);
     return $response;
 }