mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +02:00
N°8771 - Add Symfony form component to iTop core (#760)
- Add Symfony Form Component - Add Symfony CSRF security component - Add iTop default form template - Add Twig debug extension to Twig Environment - Add iTop abstract controller facility to get form builder - Add Twig filter to make trans an alias of dict_s filter
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
<?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\Security\Core\Exception;
|
||||
|
||||
use Symfony\Component\HttpKernel\Attribute\WithHttpStatus;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
|
||||
/**
|
||||
* AuthenticationException is the base class for all authentication exceptions.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Alexander <iam.asm89@gmail.com>
|
||||
*/
|
||||
#[WithHttpStatus(401)]
|
||||
class AuthenticationException extends RuntimeException
|
||||
{
|
||||
private ?TokenInterface $token = null;
|
||||
|
||||
public function getToken(): ?TokenInterface
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setToken(TokenInterface $token)
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the necessary state of the object for serialization purposes.
|
||||
*
|
||||
* There is no need to serialize any entry, they should be returned as-is.
|
||||
* If you extend this method, keep in mind you MUST guarantee parent data is present in the state.
|
||||
* Here is an example of how to extend this method:
|
||||
* <code>
|
||||
* public function __serialize(): array
|
||||
* {
|
||||
* return [$this->childAttribute, parent::__serialize()];
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @see __unserialize()
|
||||
*/
|
||||
public function __serialize(): array
|
||||
{
|
||||
return [$this->token, $this->code, $this->message, $this->file, $this->line];
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the object state from an array given by __serialize().
|
||||
*
|
||||
* There is no need to unserialize any entry in $data, they are already ready-to-use.
|
||||
* If you extend this method, keep in mind you MUST pass the parent data to its respective class.
|
||||
* Here is an example of how to extend this method:
|
||||
* <code>
|
||||
* public function __unserialize(array $data): void
|
||||
* {
|
||||
* [$this->childAttribute, $parentData] = $data;
|
||||
* parent::__unserialize($parentData);
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @see __serialize()
|
||||
*/
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
[$this->token, $this->code, $this->message, $this->file, $this->line] = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message key to be used by the translation component.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessageKey()
|
||||
{
|
||||
return 'An authentication exception occurred.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Message data to be used by the translation component.
|
||||
*/
|
||||
public function getMessageData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user