Ajout des vendor
This commit is contained in:
152
vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php
vendored
Normal file
152
vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Attribute;
|
||||
|
||||
/**
|
||||
* This class relates to session attribute storage.
|
||||
*
|
||||
* @implements \IteratorAggregate<string, mixed>
|
||||
*/
|
||||
class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Countable
|
||||
{
|
||||
private $name = 'attributes';
|
||||
private $storageKey;
|
||||
|
||||
protected $attributes = [];
|
||||
|
||||
/**
|
||||
* @param string $storageKey The key used to store attributes in the session
|
||||
*/
|
||||
public function __construct(string $storageKey = '_sf2_attributes')
|
||||
{
|
||||
$this->storageKey = $storageKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function initialize(array &$attributes)
|
||||
{
|
||||
$this->attributes = &$attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStorageKey()
|
||||
{
|
||||
return $this->storageKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has(string $name)
|
||||
{
|
||||
return \array_key_exists($name, $this->attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get(string $name, $default = null)
|
||||
{
|
||||
return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set(string $name, $value)
|
||||
{
|
||||
$this->attributes[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function replace(array $attributes)
|
||||
{
|
||||
$this->attributes = [];
|
||||
foreach ($attributes as $key => $value) {
|
||||
$this->set($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function remove(string $name)
|
||||
{
|
||||
$retval = null;
|
||||
if (\array_key_exists($name, $this->attributes)) {
|
||||
$retval = $this->attributes[$name];
|
||||
unset($this->attributes[$name]);
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$return = $this->attributes;
|
||||
$this->attributes = [];
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator for attributes.
|
||||
*
|
||||
* @return \ArrayIterator<string, mixed>
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
{
|
||||
return new \ArrayIterator($this->attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of attributes.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return \count($this->attributes);
|
||||
}
|
||||
}
|
61
vendor/symfony/http-foundation/Session/Attribute/AttributeBagInterface.php
vendored
Normal file
61
vendor/symfony/http-foundation/Session/Attribute/AttributeBagInterface.php
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Attribute;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
|
||||
|
||||
/**
|
||||
* Attributes store.
|
||||
*
|
||||
* @author Drak <drak@zikula.org>
|
||||
*/
|
||||
interface AttributeBagInterface extends SessionBagInterface
|
||||
{
|
||||
/**
|
||||
* Checks if an attribute is defined.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has(string $name);
|
||||
|
||||
/**
|
||||
* Returns an attribute.
|
||||
*
|
||||
* @param mixed $default The default value if not found
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $name, $default = null);
|
||||
|
||||
/**
|
||||
* Sets an attribute.
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function set(string $name, $value);
|
||||
|
||||
/**
|
||||
* Returns attributes.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function all();
|
||||
|
||||
public function replace(array $attributes);
|
||||
|
||||
/**
|
||||
* Removes an attribute.
|
||||
*
|
||||
* @return mixed The removed value or null when it does not exist
|
||||
*/
|
||||
public function remove(string $name);
|
||||
}
|
161
vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php
vendored
Normal file
161
vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php
vendored
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Attribute;
|
||||
|
||||
trigger_deprecation('symfony/http-foundation', '5.3', 'The "%s" class is deprecated.', NamespacedAttributeBag::class);
|
||||
|
||||
/**
|
||||
* This class provides structured storage of session attributes using
|
||||
* a name spacing character in the key.
|
||||
*
|
||||
* @author Drak <drak@zikula.org>
|
||||
*
|
||||
* @deprecated since Symfony 5.3
|
||||
*/
|
||||
class NamespacedAttributeBag extends AttributeBag
|
||||
{
|
||||
private $namespaceCharacter;
|
||||
|
||||
/**
|
||||
* @param string $storageKey Session storage key
|
||||
* @param string $namespaceCharacter Namespace character to use in keys
|
||||
*/
|
||||
public function __construct(string $storageKey = '_sf2_attributes', string $namespaceCharacter = '/')
|
||||
{
|
||||
$this->namespaceCharacter = $namespaceCharacter;
|
||||
parent::__construct($storageKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has(string $name)
|
||||
{
|
||||
// reference mismatch: if fixed, re-introduced in array_key_exists; keep as it is
|
||||
$attributes = $this->resolveAttributePath($name);
|
||||
$name = $this->resolveKey($name);
|
||||
|
||||
if (null === $attributes) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return \array_key_exists($name, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get(string $name, $default = null)
|
||||
{
|
||||
// reference mismatch: if fixed, re-introduced in array_key_exists; keep as it is
|
||||
$attributes = $this->resolveAttributePath($name);
|
||||
$name = $this->resolveKey($name);
|
||||
|
||||
if (null === $attributes) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return \array_key_exists($name, $attributes) ? $attributes[$name] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set(string $name, $value)
|
||||
{
|
||||
$attributes = &$this->resolveAttributePath($name, true);
|
||||
$name = $this->resolveKey($name);
|
||||
$attributes[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function remove(string $name)
|
||||
{
|
||||
$retval = null;
|
||||
$attributes = &$this->resolveAttributePath($name);
|
||||
$name = $this->resolveKey($name);
|
||||
if (null !== $attributes && \array_key_exists($name, $attributes)) {
|
||||
$retval = $attributes[$name];
|
||||
unset($attributes[$name]);
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a path in attributes property and returns it as a reference.
|
||||
*
|
||||
* This method allows structured namespacing of session attributes.
|
||||
*
|
||||
* @param string $name Key name
|
||||
* @param bool $writeContext Write context, default false
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function &resolveAttributePath(string $name, bool $writeContext = false)
|
||||
{
|
||||
$array = &$this->attributes;
|
||||
$name = (str_starts_with($name, $this->namespaceCharacter)) ? substr($name, 1) : $name;
|
||||
|
||||
// Check if there is anything to do, else return
|
||||
if (!$name) {
|
||||
return $array;
|
||||
}
|
||||
|
||||
$parts = explode($this->namespaceCharacter, $name);
|
||||
if (\count($parts) < 2) {
|
||||
if (!$writeContext) {
|
||||
return $array;
|
||||
}
|
||||
|
||||
$array[$parts[0]] = [];
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
unset($parts[\count($parts) - 1]);
|
||||
|
||||
foreach ($parts as $part) {
|
||||
if (null !== $array && !\array_key_exists($part, $array)) {
|
||||
if (!$writeContext) {
|
||||
$null = null;
|
||||
|
||||
return $null;
|
||||
}
|
||||
|
||||
$array[$part] = [];
|
||||
}
|
||||
|
||||
$array = &$array[$part];
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the key from the name.
|
||||
*
|
||||
* This is the last part in a dot separated string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function resolveKey(string $name)
|
||||
{
|
||||
if (false !== $pos = strrpos($name, $this->namespaceCharacter)) {
|
||||
$name = substr($name, $pos + 1);
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user