Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Service/TargetBlockFormProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function buildTargetBlockConfigurationForm(string $plugin_id, array $conf
public function validateTargetBlock(FormStateInterface $form_state, array $configuration): void {
$target_block_plugin = $form_state->getValue(['target_block', 'id']);
if (!empty($target_block_plugin)) {
$block_config = $form_state->getValue(['target_block', 'config']) ?? $configuration['target_block']['config'] ?? [];
$block_config = $form_state->getValue(['target_block', 'config', 'block_config']) ?? $configuration['target_block']['config'] ?? [];

try {
$this->blockManager->createInstance($target_block_plugin, $block_config);
Expand Down Expand Up @@ -149,7 +149,7 @@ public function submitTargetBlock(FormStateInterface $form_state): array {
$configuration['target_block']['id'] = $target_plugin_id;

if (!empty($target_plugin_id)) {
$block_config = $form_state->getValue(['target_block', 'config']) ?? [];
$block_config = $form_state->getValue(['target_block', 'config', 'block_config']) ?? [];

try {
$target_block = $this->blockManager->createInstance($target_plugin_id, $block_config);
Expand Down
14 changes: 7 additions & 7 deletions tests/src/Unit/TargetBlockFormProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public function testValidateTargetBlockValid(): void {
if ($key === ['target_block', 'id']) {
return 'valid_block';
}
if ($key === ['target_block', 'config']) {
if ($key === ['target_block', 'config', 'block_config']) {
return ['some_config' => 'value'];
}
$this->fail('Unexpected getValue call with key: ' . print_r($key, TRUE));
Expand Down Expand Up @@ -300,7 +300,7 @@ public function testValidateTargetBlockInvalid(): void {
if ($key === ['target_block', 'id']) {
return 'invalid_block';
}
if ($key === ['target_block', 'config']) {
if ($key === ['target_block', 'config', 'block_config']) {
return [];
}
$this->fail('Unexpected getValue call with key: ' . print_r($key, TRUE));
Expand Down Expand Up @@ -368,7 +368,7 @@ public function testValidateTargetBlockConfigurationFallback(): void {
if ($key === ['target_block', 'id']) {
return 'test_block';
}
if ($key === ['target_block', 'config']) {
if ($key === ['target_block', 'config', 'block_config']) {
return NULL;
}
$this->fail('Unexpected getValue call with key: ' . print_r($key, TRUE));
Expand Down Expand Up @@ -406,7 +406,7 @@ public function testSubmitTargetBlockSimple(): void {
if ($key === ['target_block', 'id']) {
return 'simple_block';
}
if ($key === ['target_block', 'config']) {
if ($key === ['target_block', 'config', 'block_config']) {
return ['block_setting' => 'value'];
}
$this->fail('Unexpected getValue call with key: ' . print_r($key, TRUE));
Expand Down Expand Up @@ -453,7 +453,7 @@ public function testSubmitTargetBlockConfigurable(): void {
if ($key === ['target_block', 'id']) {
return 'configurable_block';
}
if ($key === ['target_block', 'config']) {
if ($key === ['target_block', 'config', 'block_config']) {
return ['user_setting' => 'user_value'];
}
// @phpstan-ignore-next-line
Expand Down Expand Up @@ -500,7 +500,7 @@ public function testSubmitTargetBlockContextAware(): void {
if ($key === ['target_block', 'id']) {
return 'context_aware_block';
}
if ($key === ['target_block', 'config']) {
if ($key === ['target_block', 'config', 'block_config']) {
return ['setting' => 'value'];
}
// @phpstan-ignore-next-line
Expand Down Expand Up @@ -575,7 +575,7 @@ public function testSubmitTargetBlockPluginException(): void {
if ($key === ['target_block', 'id']) {
return 'invalid_block';
}
if ($key === ['target_block', 'config']) {
if ($key === ['target_block', 'config', 'block_config']) {
return ['setting' => 'value'];
}
$this->fail('Unexpected getValue call with key: ' . print_r($key, TRUE));
Expand Down
Loading