|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Illuminate\Session; |
| 4 | + |
| 5 | +use BadMethodCallException; |
| 6 | +use Symfony\Component\HttpFoundation\Session\SessionBagInterface; |
| 7 | +use Symfony\Component\HttpFoundation\Session\SessionInterface; |
| 8 | +use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; |
| 9 | + |
| 10 | +class SymfonySessionDecorator implements SessionInterface |
| 11 | +{ |
| 12 | + /** |
| 13 | + * The underlying Laravel session store. |
| 14 | + * |
| 15 | + * @var \Illuminate\Session\Store |
| 16 | + */ |
| 17 | + protected $store; |
| 18 | + |
| 19 | + /** |
| 20 | + * Create a new session decorator. |
| 21 | + * |
| 22 | + * @param \Illuminate\Session\Store $store |
| 23 | + * @return void |
| 24 | + */ |
| 25 | + public function __construct(Store $store) |
| 26 | + { |
| 27 | + $this->store = $store; |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * {@inheritdoc} |
| 32 | + */ |
| 33 | + public function start(): bool |
| 34 | + { |
| 35 | + return $this->store->start(); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * {@inheritdoc} |
| 40 | + */ |
| 41 | + public function getId(): string |
| 42 | + { |
| 43 | + return $this->store->getId(); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * {@inheritdoc} |
| 48 | + */ |
| 49 | + public function setId(string $id) |
| 50 | + { |
| 51 | + $this->store->setId($id); |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * {@inheritdoc} |
| 56 | + */ |
| 57 | + public function getName(): string |
| 58 | + { |
| 59 | + return $this->store->getName(); |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * {@inheritdoc} |
| 64 | + */ |
| 65 | + public function setName(string $name) |
| 66 | + { |
| 67 | + $this->store->setName($name); |
| 68 | + } |
| 69 | + |
| 70 | + /** |
| 71 | + * {@inheritdoc} |
| 72 | + */ |
| 73 | + public function invalidate(int $lifetime = null): bool |
| 74 | + { |
| 75 | + $this->store->invalidate(); |
| 76 | + |
| 77 | + return true; |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * {@inheritdoc} |
| 82 | + */ |
| 83 | + public function migrate(bool $destroy = false, int $lifetime = null): bool |
| 84 | + { |
| 85 | + $this->store->migrate($destroy); |
| 86 | + |
| 87 | + return true; |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * {@inheritdoc} |
| 92 | + */ |
| 93 | + public function save() |
| 94 | + { |
| 95 | + $this->store->save(); |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * {@inheritdoc} |
| 100 | + */ |
| 101 | + public function has(string $name): bool |
| 102 | + { |
| 103 | + return $this->store->has($name); |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * {@inheritdoc} |
| 108 | + */ |
| 109 | + public function get(string $name, mixed $default = null): mixed |
| 110 | + { |
| 111 | + return $this->store->get($name, $default); |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * {@inheritdoc} |
| 116 | + */ |
| 117 | + public function set(string $name, mixed $value) |
| 118 | + { |
| 119 | + $this->store->put($name, $value); |
| 120 | + } |
| 121 | + |
| 122 | + /** |
| 123 | + * {@inheritdoc} |
| 124 | + */ |
| 125 | + public function all(): array |
| 126 | + { |
| 127 | + return $this->store->all(); |
| 128 | + } |
| 129 | + |
| 130 | + /** |
| 131 | + * {@inheritdoc} |
| 132 | + */ |
| 133 | + public function replace(array $attributes) |
| 134 | + { |
| 135 | + $this->store->replace($attributes); |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * {@inheritdoc} |
| 140 | + */ |
| 141 | + public function remove(string $name): mixed |
| 142 | + { |
| 143 | + return $this->store->remove($name); |
| 144 | + } |
| 145 | + |
| 146 | + /** |
| 147 | + * {@inheritdoc} |
| 148 | + */ |
| 149 | + public function clear() |
| 150 | + { |
| 151 | + $this->store->flush(); |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * {@inheritdoc} |
| 156 | + */ |
| 157 | + public function isStarted(): bool |
| 158 | + { |
| 159 | + return $this->store->isStarted(); |
| 160 | + } |
| 161 | + |
| 162 | + /** |
| 163 | + * {@inheritdoc} |
| 164 | + */ |
| 165 | + public function registerBag(SessionBagInterface $bag) |
| 166 | + { |
| 167 | + throw new BadMethodCallException('Method not implemented by Laravel.'); |
| 168 | + } |
| 169 | + |
| 170 | + /** |
| 171 | + * {@inheritdoc} |
| 172 | + */ |
| 173 | + public function getBag(string $name): SessionBagInterface |
| 174 | + { |
| 175 | + throw new BadMethodCallException('Method not implemented by Laravel.'); |
| 176 | + } |
| 177 | + |
| 178 | + /** |
| 179 | + * {@inheritdoc} |
| 180 | + */ |
| 181 | + public function getMetadataBag(): MetadataBag |
| 182 | + { |
| 183 | + throw new BadMethodCallException('Method not implemented by Laravel.'); |
| 184 | + } |
| 185 | +} |
0 commit comments