<?php

//namespace Drupal\restaurant\Controller\MultipageController;

//use Drupal\Core\Controller\ControllerBase;
use Drupal\restaurant\Controller\AppController;
use Drupal\restaurant\Database\Db;
use Drupal\restaurant\Database\Table;
use Drupal\restaurant\Helper;
use Drupal\restaurant\View\View;
use Drupal\restaurant\Call\Call;
use Drupal\restaurant\Registry\Registry;
use Drupal\restaurant\App\Base;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Session\SessionManagerInterface;
use Drupal\user\PrivateTempStoreFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;

abstract class MultipageController extends AppController implements Base
{

  /**
  * @var \Drupal\user\PrivateTempStoreFactory
  */
  protected $tempStoreFactory;

 /**
  * @var \Drupal\Core\Session\SessionManagerInterface
  */
  private $sessionManager;

 /**
  * @var \Drupal\Core\Session\AccountInterface
  */
  public $currentUser;

 /**
  * @var \Drupal\user\PrivateTempStore
  */
  protected $store;


  public function __construct($temp_store_factory, SessionManagerInterface $session_manager, AccountInterface $current_user)
  {
    $this->tempStoreFactory = $temp_store_factory;
    $this->sessionManager = $session_manager;
    $this->currentUser = $current_user;

    $this->store = $this->tempStoreFactory->get('multistep_data');
    parent::__construct();
  }

  /**
    * {@inheritdoc}
    */
   public static function create(ContainerInterface $container)
   {
     return new static(
       $container->get('tempstore.private'),
       $container->get('session_manager'),
       $container->get('current_user')
     );

     // 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();
     }
   }
}
