class DeprecatedCsrfTokenController in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/tests/modules/csrf_test/src/Controller/DeprecatedCsrfTokenController.php \Drupal\csrf_test\Controller\DeprecatedCsrfTokenController
Returns responses for Deprecated CSRF token routes.
This controller tests using the deprecated CSRF token key 'rest'.
@todo Remove this before drupal:10.0.0 https://www.drupal.org/node/3115308
Hierarchy
- class \Drupal\csrf_test\Controller\DeprecatedCsrfTokenController implements ContainerInjectionInterface
Expanded class hierarchy of DeprecatedCsrfTokenController
See also
\Drupal\Core\Access\CsrfRequestHeaderAccessCheck::access()
File
- core/
modules/ system/ tests/ modules/ csrf_test/ src/ Controller/ DeprecatedCsrfTokenController.php, line 19
Namespace
Drupal\csrf_test\ControllerView source
class DeprecatedCsrfTokenController implements ContainerInjectionInterface {
/**
* The CSRF token generator.
*
* @var \Drupal\Core\Access\CsrfTokenGenerator
*/
protected $tokenGenerator;
/**
* Constructs a new CsrfTokenController object.
*
* @param \Drupal\Core\Access\CsrfTokenGenerator $token_generator
* The CSRF token generator.
*/
public function __construct(CsrfTokenGenerator $token_generator) {
$this->tokenGenerator = $token_generator;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('csrf_token'));
}
/**
* Returns a CSRF using the deprecated 'rest' value protecting session token.
*
* @return \Symfony\Component\HttpFoundation\Response
* The response object.
*/
public function csrfToken() {
return new Response($this->tokenGenerator
->get('rest'), 200, [
'Content-Type' => 'text/plain',
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeprecatedCsrfTokenController:: |
protected | property | The CSRF token generator. | |
DeprecatedCsrfTokenController:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
DeprecatedCsrfTokenController:: |
public | function | Returns a CSRF using the deprecated 'rest' value protecting session token. | |
DeprecatedCsrfTokenController:: |
public | function | Constructs a new CsrfTokenController object. |