Skip to content
Snippets Groups Projects

Update message "Render %s callbacks must be methods of a class that implements" with attribute

All threads resolved!
Files
31
@@ -4,15 +4,14 @@
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Security\TrustedCallbackInterface;
use Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface;
use Symfony\Component\Routing\Route;
use Drupal\Core\Security\Attribute\TrustedCallback;
/**
* Processes the outbound route to handle the CSRF token.
*/
class RouteProcessorCsrf implements OutboundRouteProcessorInterface, TrustedCallbackInterface {
class RouteProcessorCsrf implements OutboundRouteProcessorInterface {
/**
* The CSRF token generator.
*
@@ -70,6 +69,7 @@ public function processOutbound($route_name, Route $route, array &$parameters, B
* @return array
* A renderable array representing the CSRF token.
*/
#[TrustedCallback]
public function renderPlaceholderCsrfToken($path) {
return [
'#markup' => $this->csrfToken->get($path),
@@ -82,11 +82,4 @@ public function renderPlaceholderCsrfToken($path) {
];
}
/**
* {@inheritdoc}
*/
public static function trustedCallbacks() {
return ['renderPlaceholderCsrfToken'];
}
}
Loading