| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of the Symfony package. |
| 5 |
* |
| 6 |
* (c) Fabien Potencier <[email protected]> |
| 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 Give\Vendors\Symfony\Component\HttpFoundation\Session; |
| 13 |
|
| 14 |
/** |
| 15 |
* @author Nicolas Grekas <[email protected]> |
| 16 |
* |
| 17 |
* @internal |
| 18 |
*/ |
| 19 |
final class SessionBagProxy implements SessionBagInterface |
| 20 |
{ |
| 21 |
private $bag; |
| 22 |
private $data; |
| 23 |
private $usageIndex; |
| 24 |
private $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 = $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 |
/** |
| 58 |
* {@inheritdoc} |
| 59 |
*/ |
| 60 |
public function getName(): string |
| 61 |
{ |
| 62 |
return $this->bag->getName(); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* {@inheritdoc} |
| 67 |
*/ |
| 68 |
public function initialize(array &$array): void |
| 69 |
{ |
| 70 |
++$this->usageIndex; |
| 71 |
if ($this->usageReporter && 0 <= $this->usageIndex) { |
| 72 |
($this->usageReporter)(); |
| 73 |
} |
| 74 |
|
| 75 |
$this->data[$this->bag->getStorageKey()] = &$array; |
| 76 |
|
| 77 |
$this->bag->initialize($array); |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* {@inheritdoc} |
| 82 |
*/ |
| 83 |
public function getStorageKey(): string |
| 84 |
{ |
| 85 |
return $this->bag->getStorageKey(); |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 89 |
* {@inheritdoc} |
| 90 |
*/ |
| 91 |
public function clear() |
| 92 |
{ |
| 93 |
return $this->bag->clear(); |
| 94 |
} |
| 95 |
} |
| 96 |
|