By longwave on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
10.1.x
Introduced in version:
10.1.0
Description:
Previously, trusted callbacks must be implemented with an interface and method declaring the name of the trusted methods:
use Drupal\Core\Security\TrustedCallbackInterface;
class SomeClass implements TrustedCallbackInterface {
public static function someCallback(...) {
...
}
/**
* {@inheritdoc}
*/
public static function trustedCallbacks() {
return ['someCallback'];
}
}
Instead, the interface is no longer required and you can now mark the callback directly with a PHP attribute:
use Drupal\Core\Security\Attribute\TrustedCallback;
class SomeClass {
#[TrustedCallback]
public static function someCallback(...) {
...
}
}
Impacts:
Module developers
Themers