By kristiaanvandeneynde on
Change record status:
Draft (View all draft change records)
Project:
Introduced in branch:
12.x
Introduced in version:
12.0.0-beta3
Issue links:
Description:
ArgumentValidatorPluginBase::validateArgument() now takes a second argument to gather cacheable metadata.
Before
public function validateArgument($arg) {
After
public function validateArgument($arg /* , RefinableCacheableDependencyInterface $cacheability = new CacheableMetadata() */) {
Starting from Drupal 13.0.0, the signature will be updated to require the new argument.
Adapting your code
Adjust your plugin method to start like this if your plugin extends the Entity plugin:
public function validateArgument($argument /* , RefinableCacheableDependencyInterface $cacheability = new CacheableMetadata() */) {
$this->cacheability = func_get_args()[1] ?? new CacheableMetadata();
Otherwise, this is fine too:
public function validateArgument($argument /* , RefinableCacheableDependencyInterface $cacheability = new CacheableMetadata() */) {
$cacheability = func_get_args()[1] ?? new CacheableMetadata();
After Drupal 13 releases and is your minimum supported version, you can drop that line altogether. Plugins extending Entity and not calling the parent will still need to assign it to the property.
Impacts:
Module developers