<?php

namespace App\Actions\Session;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use App\Services\ApiService;
use App\Modules\FSAPI\DuplicatSessionException;
use App\View\Pages;
use App\Mode\Session as S;
use App\Model\Exception\EmptyNumberException;
use App\Model\Exception\UserExistException;

class GetSessionListAction{

    private $rest;
    private $view;
    
    public function __construct(ApiService $api, Pages $view)
    {
	$this->rest = $api;
	$this->view = $view;
    }

    public function __invoke(ServerRequestInterface $request,
			     ResponseInterface $response, array $args): ResponseInterface
    {
	/* $users = [];
	   if(isset($_SESSION['select'])){
	   foreach ($_SESSION['select'] as $user => $val){
	   $users[] = $user;
	   }
	   }
	   $data = $this->ldap->get_users($users);
	   $session = [];
	   foreach ($data as $u){
	   $session[$_SESSION['select'][$u['cn'][0]]][] = $u;
	   } */
	$current_session = $this->rest->session();
	return $this->view->render($request, $response, 'session.html', [
	    'current_session' => $current_session,
	    'currentPath' => $_SERVER['REQUEST_URI']
	]);
    }
    
}
