diff --git a/modules/ui_patterns_blocks/src/Plugin/Derivative/ComponentBlock.php b/modules/ui_patterns_blocks/src/Plugin/Derivative/ComponentBlock.php index 6ac1ded561e425222b17c6a48285e34632662342..c4b8e5da8f5993392b593a11d3b9362fb81abfe3 100644 --- a/modules/ui_patterns_blocks/src/Plugin/Derivative/ComponentBlock.php +++ b/modules/ui_patterns_blocks/src/Plugin/Derivative/ComponentBlock.php @@ -50,6 +50,7 @@ class ComponentBlock extends DeriverBase implements ContainerDeriverInterface { $this->derivatives[$component_id] = $base_plugin_definition; $this->derivatives[$component_id]['admin_label'] = $component['annotated_name'] ?? $component['name'] ?? $component['id']; $this->derivatives[$component_id]['_block_ui_hidden'] = FALSE; + $this->derivatives[$component_id]['provider'] = 'ui_patterns_blocks'; } return $this->derivatives; diff --git a/src/Plugin/UiPatterns/Source/BlockSource.php b/src/Plugin/UiPatterns/Source/BlockSource.php index dad2a61a9e56755e3a636f82920622160c2ce647..745c79854995c64b7e625c941522193a1e21d1af 100644 --- a/src/Plugin/UiPatterns/Source/BlockSource.php +++ b/src/Plugin/UiPatterns/Source/BlockSource.php @@ -10,6 +10,8 @@ use Drupal\Component\Utility\Html; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Block\BlockManagerInterface; use Drupal\Core\Block\BlockPluginInterface; +use Drupal\Core\Config\Config; +use Drupal\Core\Config\NullStorage; use Drupal\Core\Entity\EntityDisplayBase; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; @@ -84,7 +86,7 @@ class BlockSource extends SourcePluginBase { $container->get('module_handler'), $container->get('plugin.manager.block'), $container->get('plugin_form.factory'), - $container->get('context.handler') + $container->get('context.handler'), ); return $instance; } @@ -113,8 +115,12 @@ class BlockSource extends SourcePluginBase { $block = \Drupal::service('plugin.manager.block')->createInstance($plugin_id, []); if ($block instanceof BlockPluginInterface) { $block->submitConfigurationForm($element, $subform_state); - $configuration = $block->getConfiguration(); - $form_state->setValue(array_merge($element['#parents'], [$plugin_id]), $configuration); + $config = new Config("block.block.ui_patterns", new NullStorage(), \Drupal::service('event_dispatcher'), \Drupal::service('config.typed')); + $config->setData([ + "plugin" => $plugin_id, + "settings" => $block->getConfiguration(), + ])->save(); + $form_state->setValue(array_merge($element['#parents'], [$plugin_id]), $config->getRawData()['settings']); } return $element; } @@ -132,7 +138,6 @@ class BlockSource extends SourcePluginBase { * {@inheritdoc} */ public function getPropValue(): mixed { - // Create a block entity. $this->block = $this->getBlock($this->getSetting('plugin_id') ?? ''); if (!$this->block) { return []; @@ -197,7 +202,6 @@ class BlockSource extends SourcePluginBase { ]; $block = $this->getBlock($plugin_id); if ($block) { - // Create a block entity. $form['#tree'] = TRUE; // $form['#process'] = [ '::validateForm']; $form[$plugin_id] = [];