Problem/Motivation
Ran into this while working on #3364109: Configuration schema & required values: add test coverage for `nullable: true` validation support.
signature \Drupal\Component\Plugin\ConfigurableInterface::setConfiguration(array $configuration)
(note type hint)
🆚
signature \Drupal\Component\Plugin\LazyPluginCollection::setConfiguration($configuration)
(note NO type hint)
🆚\Drupal\Core\Plugin\DefaultSingleLazyPluginCollection::setConfiguration()
implementation of LazyPluginCollection::setConfiguration()
:
public function setConfiguration($configuration) {
$this->configuration = $configuration;
$plugin = $this->get($this->instanceId);
if ($plugin instanceof ConfigurableInterface) {
$plugin->setConfiguration($configuration);
}
return $this;
}
Steps to reproduce
$block = Block::load('block.block.olivero_content');
$block->set('settings', NULL);
$typed_data = $this->container->get('typed_data_manager');
$definition = $typed_data->createDataDefinition('entity:block');
$violations = $typed_data->create($definition, $block)->validate();
Results in:
TypeError: Drupal\Core\Block\BlockBase::setConfiguration(): Argument #1 ($configuration) must be of type array, null given, called in /Users/wim.leers/core/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php on line 85
/Users/wim.leers/core/core/lib/Drupal/Core/Block/BlockPluginTrait.php:79
/Users/wim.leers/core/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php:85
/Users/wim.leers/core/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:165
…
Same problem in \Drupal\Core\Plugin\DefaultLazyPluginCollection::setConfiguration()
(try visibility
on
Proposed resolution
Make\Drupal\Core\Plugin\DefaultSingleLazyPluginCollection::setConfiguration()
\Drupal\Core\Plugin\DefaultLazyPluginCollection::setConfiguration()
narrow the data it receives
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
N/A