| 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 Symfony\Component\HttpFoundation\Session\Storage; |
| 13 |
|
| 14 |
use Symfony\Component\HttpFoundation\Request; |
| 15 |
|
| 16 |
// Help opcache.preload discover always-needed symbols |
| 17 |
class_exists(NativeSessionStorage::class); |
| 18 |
|
| 19 |
/** |
| 20 |
* @author Jérémy Derussé <[email protected]> |
| 21 |
*/ |
| 22 |
class NativeSessionStorageFactory implements SessionStorageFactoryInterface |
| 23 |
{ |
| 24 |
private $options; |
| 25 |
private $handler; |
| 26 |
private $metaBag; |
| 27 |
private $secure; |
| 28 |
|
| 29 |
/** |
| 30 |
* @see NativeSessionStorage constructor. |
| 31 |
*/ |
| 32 |
public function __construct(array $options = [], $handler = null, ?MetadataBag $metaBag = null, bool $secure = false) |
| 33 |
{ |
| 34 |
$this->options = $options; |
| 35 |
$this->handler = $handler; |
| 36 |
$this->metaBag = $metaBag; |
| 37 |
$this->secure = $secure; |
| 38 |
} |
| 39 |
|
| 40 |
public function createStorage(?Request $request): SessionStorageInterface |
| 41 |
{ |
| 42 |
$storage = new NativeSessionStorage($this->options, $this->handler, $this->metaBag); |
| 43 |
if ($this->secure && $request && $request->isSecure()) { |
| 44 |
$storage->setOptions(['cookie_secure' => true]); |
| 45 |
} |
| 46 |
|
| 47 |
return $storage; |
| 48 |
} |
| 49 |
} |
| 50 |
|