Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <fabien@symfony.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Symfony\Component\HttpFoundation\Session;
13
 
14
/**
15
 * @author Nicolas Grekas <p@tchwork.com>
16
 *
17
 * @internal
18
 */
19
final class SessionBagProxy implements SessionBagInterface
20
{
21
    private SessionBagInterface $bag;
22
    private array $data;
23
    private ?int $usageIndex;
24
    private ?\Closure $usageReporter;
25
 
26
    public function __construct(SessionBagInterface $bag, array &$data, ?int &$usageIndex, ?callable $usageReporter)
27
    {
28
        $this->bag = $bag;
29
        $this->data = &$data;
30
        $this->usageIndex = &$usageIndex;
31
        $this->usageReporter = null === $usageReporter ? null : $usageReporter(...);
32
    }
33
 
34
    public function getBag(): SessionBagInterface
35
    {
36
        ++$this->usageIndex;
37
        if ($this->usageReporter && 0 <= $this->usageIndex) {
38
            ($this->usageReporter)();
39
        }
40
 
41
        return $this->bag;
42
    }
43
 
44
    public function isEmpty(): bool
45
    {
46
        if (!isset($this->data[$this->bag->getStorageKey()])) {
47
            return true;
48
        }
49
        ++$this->usageIndex;
50
        if ($this->usageReporter && 0 <= $this->usageIndex) {
51
            ($this->usageReporter)();
52
        }
53
 
54
        return empty($this->data[$this->bag->getStorageKey()]);
55
    }
56
 
57
    public function getName(): string
58
    {
59
        return $this->bag->getName();
60
    }
61
 
62
    public function initialize(array &$array): void
63
    {
64
        ++$this->usageIndex;
65
        if ($this->usageReporter && 0 <= $this->usageIndex) {
66
            ($this->usageReporter)();
67
        }
68
 
69
        $this->data[$this->bag->getStorageKey()] = &$array;
70
 
71
        $this->bag->initialize($array);
72
    }
73
 
74
    public function getStorageKey(): string
75
    {
76
        return $this->bag->getStorageKey();
77
    }
78
 
79
    public function clear(): mixed
80
    {
81
        return $this->bag->clear();
82
    }
83
}