Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function authenticate(Request $request)
 {
     // Global $user is deprecated, but the session system is still based on it.
     global $user;
     $this->sessionManager->start();
     if ($this->sessionManager->isStarted()) {
         return $user;
     }
     return NULL;
 }
 /**
  * {@inheritdoc}.
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Start a manual session for anonymous users.
     if ($this->currentUser->isAnonymous() && !isset($_SESSION['multistep_form_holds_session'])) {
         $_SESSION['multistep_form_holds_session'] = true;
         $this->sessionManager->start();
     }
     $form = array();
     $form['actions']['#type'] = 'actions';
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Submit'), '#button_type' => 'primary', '#weight' => 10);
     return $form;
 }
 /**
  * Set header for session testing.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  *   The Event to process.
  */
 public function onKernelRequestSessionTest(GetResponseEvent $event)
 {
     $this->emptySession = (int) (!$this->sessionManager->start());
 }