1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace DMK\MKSamlAuth\Container; |
6
|
|
|
|
7
|
|
|
use DMK\MKSamlAuth\Session\PhpSession; |
8
|
|
|
use LightSaml\Build\Container\SystemContainerInterface; |
9
|
|
|
use LightSaml\Provider\TimeProvider\SystemTimeProvider; |
10
|
|
|
use LightSaml\Provider\TimeProvider\TimeProviderInterface; |
11
|
|
|
use Psr\Log\LoggerInterface; |
12
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
13
|
|
|
use Symfony\Component\HttpFoundation\Request; |
14
|
|
|
use Symfony\Component\HttpFoundation\Session\Session; |
15
|
|
|
use TYPO3\CMS\Core\Log\LogManager; |
16
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
17
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
18
|
|
|
|
19
|
|
|
class SystemContainer implements SystemContainerInterface, SingletonInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var SingletonContainer |
23
|
|
|
*/ |
24
|
|
|
private $container; |
25
|
|
|
|
26
|
|
|
public function __construct(SingletonContainer $container) |
27
|
|
|
{ |
28
|
|
|
$this->container = $container; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function getRequest(): Request |
32
|
|
|
{ |
33
|
|
|
return Request::createFromGlobals(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function getSession(): Session |
37
|
|
|
{ |
38
|
|
|
static $session; |
39
|
|
|
|
40
|
|
|
if ($session) { |
41
|
|
|
return $session; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return $session = new Session( |
45
|
|
|
$this->container->getInstance(PhpSession::class) |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function getTimeProvider(): TimeProviderInterface |
50
|
|
|
{ |
51
|
|
|
return $this->container->getInstance(SystemTimeProvider::class); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getEventDispatcher(): EventDispatcherInterface |
55
|
|
|
{ |
56
|
|
|
return $this->container->getInstance(EventDispatcherInterface::class); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function getLogger(): LoggerInterface |
60
|
|
|
{ |
61
|
|
|
return GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|