Loading cl_block.module +4 −2 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ */ use Drupal\cl_components\Plugin\Component; use Drupal\cl_editorial\NoThemeComponentManager; /** * Implements hook_cl_component_audit_alter(). Loading @@ -15,10 +16,11 @@ function cl_block_cl_component_audit_alter(array &$card_build, Component $compon $allowed_components = &drupal_static(__FUNCTION__); if (!isset($allowed_components)) { $settings = \Drupal::config('cl_block.settings'); $discovery = cl_components_manager(); $component_manager = \Drupal::service(NoThemeComponentManager::class); assert($component_manager instanceof NoThemeComponentManager); $allowed_components = array_map( static fn(Component $c) => $c->getId(), $discovery->getAllComponentsWithoutDupesWithFilters( $component_manager->getFilteredComponentTypes( $settings->get('allowed'), $settings->get('forbidden'), $settings->get('types'), Loading src/Form/ClBlockDialog.php +8 −7 Original line number Diff line number Diff line Loading @@ -2,9 +2,9 @@ namespace Drupal\cl_block\Form; use Drupal\cl_components\ComponentPluginManager; use Drupal\cl_components\Exception\ComponentNotFoundException; use Drupal\cl_components\Exception\InvalidComponentHookException; use Drupal\cl_editorial\NoThemeComponentManager; use Drupal\Component\Serialization\Json; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\CloseModalDialogCommand; Loading @@ -25,17 +25,18 @@ class ClBlockDialog extends FormBase { /** * Constructs a ElementEmbedDialog object. * * @param \Drupal\cl_components\ComponentPluginManager $pluginManager * The plugin manager. * @param \Drupal\cl_editorial\NoThemeComponentManager $componentManager * The component manager. */ public function __construct(protected ComponentPluginManager $pluginManager) {} public function __construct(protected NoThemeComponentManager $componentManager) { } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('plugin.manager.cl_component') $container->get(NoThemeComponentManager::class) ); } Loading Loading @@ -108,7 +109,7 @@ class ClBlockDialog extends FormBase { ], ]; try { $component = $this->pluginManager->findWithoutThemeFilter($cl_component['data-component-id'] ?? ''); $component = $this->componentManager->findWithoutThemeFilter($cl_component['data-component-id'] ?? ''); } catch (ComponentNotFoundException $e) { return $form; Loading Loading @@ -272,7 +273,7 @@ class ClBlockDialog extends FormBase { 'data-component-id', 'machine_name', ]); $component = $this->pluginManager->findWithoutThemeFilter($machine_name); $component = $this->componentManager->findWithoutThemeFilter($machine_name); } catch (ComponentNotFoundException $e) { watchdog_exception('cl_block', $e); Loading src/Form/ClComponentForm.php +6 −6 Original line number Diff line number Diff line Loading @@ -2,10 +2,10 @@ namespace Drupal\cl_block\Form; use Drupal\cl_components\Plugin\Component; use Drupal\cl_components\ComponentPluginManager; use Drupal\cl_components\Exception\ComponentNotFoundException; use Drupal\cl_components\Exception\InvalidComponentHookException; use Drupal\cl_components\Plugin\Component; use Drupal\cl_editorial\NoThemeComponentManager; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Form\FormStateInterface; Loading Loading @@ -35,13 +35,13 @@ class ClComponentForm { * The component name. * @param \Shaper\Transformation\TransformationInterface $formGenerator * The form generator. * @param \Drupal\cl_components\ComponentPluginManager $pluginManager * The component plugin manager. * @param \Drupal\cl_editorial\NoThemeComponentManager $componentManager * The component manager. */ public function __construct( protected readonly string $componentName, protected readonly TransformationInterface $formGenerator, protected readonly ComponentPluginManager $pluginManager protected readonly NoThemeComponentManager $componentManager ) { } Loading Loading @@ -178,7 +178,7 @@ class ClComponentForm { */ protected function getComponent(): Component { if (empty($this->component)) { $this->component = $this->pluginManager->findWithoutThemeFilter($this->componentName); $this->component = $this->componentManager->findWithoutThemeFilter($this->componentName); } return $this->component; } Loading src/Form/SettingsForm.php +10 −7 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ namespace Drupal\cl_block\Form; use Drupal\cl_components\ComponentPluginManager; use Drupal\cl_editorial\Form\ComponentFiltersFormTrait; use Drupal\cl_editorial\NoThemeComponentManager; use Drupal\Core\Block\BlockManagerInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\ConfigFormBase; Loading @@ -20,17 +20,20 @@ class SettingsForm extends ConfigFormBase { /** * {@inheritdoc} */ public function __construct(ConfigFactoryInterface $config_factory, private readonly ComponentPluginManager $pluginManager, private readonly BlockManagerInterface $blockManager) { } public function __construct( ConfigFactoryInterface $config_factory, private readonly NoThemeComponentManager $componentManager, private readonly BlockManagerInterface $blockManager ) {} /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { $plugin_manager = $container->get('plugin.manager.cl_component'); $component_manager = $container->get(NoThemeComponentManager::class); return new static( $container->get('config.factory'), $plugin_manager, $component_manager, $container->get('plugin.manager.block') ); } Loading @@ -56,9 +59,9 @@ class SettingsForm extends ConfigFormBase { $settings = $this->config('cl_block.settings')->get(); // I am unsure why we need this, but the component discovery is not // initialized in ajax callbacks sometimes. $plugin_manager = isset($this->pluginManager) ? $this->pluginManager : cl_components_manager(); $component_manager = $this->componentManager ?? \Drupal::service(NoThemeComponentManager::class); $message = $this->t('Set a combination of filters to control the list of components that will become blocks.'); static::buildSettingsForm($form, $form_state, $plugin_manager, $settings, [], $message); static::buildSettingsForm($form, $form_state, $component_manager, $settings, [], $message); return parent::buildForm($form, $form_state); } Loading src/Plugin/Block/ComponentBlock.php +6 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ namespace Drupal\cl_block\Plugin\Block; use Drupal\cl_block\Form\ClComponentForm; use Drupal\cl_block\Render\ComponentBlockRenderer; use Drupal\cl_components\Plugin\Component; use Drupal\cl_editorial\NoThemeComponentManager; use Drupal\Core\Block\BlockBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; Loading Loading @@ -120,7 +121,11 @@ class ComponentBlock extends BlockBase implements ContainerFactoryPluginInterfac public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { // Get the entity type and field name from the plugin ID. [, $component_name] = explode(static::DERIVATIVE_SEPARATOR, $plugin_id, 4); $form_helper = new ClComponentForm($component_name, $container->get('cl_block.form_generator'), $container->get('plugin.manager.cl_component')); $form_helper = new ClComponentForm( $component_name, $container->get('cl_block.form_generator'), $container->get(NoThemeComponentManager::class) ); return new static( $configuration, $plugin_id, Loading Loading
cl_block.module +4 −2 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ */ use Drupal\cl_components\Plugin\Component; use Drupal\cl_editorial\NoThemeComponentManager; /** * Implements hook_cl_component_audit_alter(). Loading @@ -15,10 +16,11 @@ function cl_block_cl_component_audit_alter(array &$card_build, Component $compon $allowed_components = &drupal_static(__FUNCTION__); if (!isset($allowed_components)) { $settings = \Drupal::config('cl_block.settings'); $discovery = cl_components_manager(); $component_manager = \Drupal::service(NoThemeComponentManager::class); assert($component_manager instanceof NoThemeComponentManager); $allowed_components = array_map( static fn(Component $c) => $c->getId(), $discovery->getAllComponentsWithoutDupesWithFilters( $component_manager->getFilteredComponentTypes( $settings->get('allowed'), $settings->get('forbidden'), $settings->get('types'), Loading
src/Form/ClBlockDialog.php +8 −7 Original line number Diff line number Diff line Loading @@ -2,9 +2,9 @@ namespace Drupal\cl_block\Form; use Drupal\cl_components\ComponentPluginManager; use Drupal\cl_components\Exception\ComponentNotFoundException; use Drupal\cl_components\Exception\InvalidComponentHookException; use Drupal\cl_editorial\NoThemeComponentManager; use Drupal\Component\Serialization\Json; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\CloseModalDialogCommand; Loading @@ -25,17 +25,18 @@ class ClBlockDialog extends FormBase { /** * Constructs a ElementEmbedDialog object. * * @param \Drupal\cl_components\ComponentPluginManager $pluginManager * The plugin manager. * @param \Drupal\cl_editorial\NoThemeComponentManager $componentManager * The component manager. */ public function __construct(protected ComponentPluginManager $pluginManager) {} public function __construct(protected NoThemeComponentManager $componentManager) { } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('plugin.manager.cl_component') $container->get(NoThemeComponentManager::class) ); } Loading Loading @@ -108,7 +109,7 @@ class ClBlockDialog extends FormBase { ], ]; try { $component = $this->pluginManager->findWithoutThemeFilter($cl_component['data-component-id'] ?? ''); $component = $this->componentManager->findWithoutThemeFilter($cl_component['data-component-id'] ?? ''); } catch (ComponentNotFoundException $e) { return $form; Loading Loading @@ -272,7 +273,7 @@ class ClBlockDialog extends FormBase { 'data-component-id', 'machine_name', ]); $component = $this->pluginManager->findWithoutThemeFilter($machine_name); $component = $this->componentManager->findWithoutThemeFilter($machine_name); } catch (ComponentNotFoundException $e) { watchdog_exception('cl_block', $e); Loading
src/Form/ClComponentForm.php +6 −6 Original line number Diff line number Diff line Loading @@ -2,10 +2,10 @@ namespace Drupal\cl_block\Form; use Drupal\cl_components\Plugin\Component; use Drupal\cl_components\ComponentPluginManager; use Drupal\cl_components\Exception\ComponentNotFoundException; use Drupal\cl_components\Exception\InvalidComponentHookException; use Drupal\cl_components\Plugin\Component; use Drupal\cl_editorial\NoThemeComponentManager; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Form\FormStateInterface; Loading Loading @@ -35,13 +35,13 @@ class ClComponentForm { * The component name. * @param \Shaper\Transformation\TransformationInterface $formGenerator * The form generator. * @param \Drupal\cl_components\ComponentPluginManager $pluginManager * The component plugin manager. * @param \Drupal\cl_editorial\NoThemeComponentManager $componentManager * The component manager. */ public function __construct( protected readonly string $componentName, protected readonly TransformationInterface $formGenerator, protected readonly ComponentPluginManager $pluginManager protected readonly NoThemeComponentManager $componentManager ) { } Loading Loading @@ -178,7 +178,7 @@ class ClComponentForm { */ protected function getComponent(): Component { if (empty($this->component)) { $this->component = $this->pluginManager->findWithoutThemeFilter($this->componentName); $this->component = $this->componentManager->findWithoutThemeFilter($this->componentName); } return $this->component; } Loading
src/Form/SettingsForm.php +10 −7 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ namespace Drupal\cl_block\Form; use Drupal\cl_components\ComponentPluginManager; use Drupal\cl_editorial\Form\ComponentFiltersFormTrait; use Drupal\cl_editorial\NoThemeComponentManager; use Drupal\Core\Block\BlockManagerInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\ConfigFormBase; Loading @@ -20,17 +20,20 @@ class SettingsForm extends ConfigFormBase { /** * {@inheritdoc} */ public function __construct(ConfigFactoryInterface $config_factory, private readonly ComponentPluginManager $pluginManager, private readonly BlockManagerInterface $blockManager) { } public function __construct( ConfigFactoryInterface $config_factory, private readonly NoThemeComponentManager $componentManager, private readonly BlockManagerInterface $blockManager ) {} /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { $plugin_manager = $container->get('plugin.manager.cl_component'); $component_manager = $container->get(NoThemeComponentManager::class); return new static( $container->get('config.factory'), $plugin_manager, $component_manager, $container->get('plugin.manager.block') ); } Loading @@ -56,9 +59,9 @@ class SettingsForm extends ConfigFormBase { $settings = $this->config('cl_block.settings')->get(); // I am unsure why we need this, but the component discovery is not // initialized in ajax callbacks sometimes. $plugin_manager = isset($this->pluginManager) ? $this->pluginManager : cl_components_manager(); $component_manager = $this->componentManager ?? \Drupal::service(NoThemeComponentManager::class); $message = $this->t('Set a combination of filters to control the list of components that will become blocks.'); static::buildSettingsForm($form, $form_state, $plugin_manager, $settings, [], $message); static::buildSettingsForm($form, $form_state, $component_manager, $settings, [], $message); return parent::buildForm($form, $form_state); } Loading
src/Plugin/Block/ComponentBlock.php +6 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ namespace Drupal\cl_block\Plugin\Block; use Drupal\cl_block\Form\ClComponentForm; use Drupal\cl_block\Render\ComponentBlockRenderer; use Drupal\cl_components\Plugin\Component; use Drupal\cl_editorial\NoThemeComponentManager; use Drupal\Core\Block\BlockBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; Loading Loading @@ -120,7 +121,11 @@ class ComponentBlock extends BlockBase implements ContainerFactoryPluginInterfac public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { // Get the entity type and field name from the plugin ID. [, $component_name] = explode(static::DERIVATIVE_SEPARATOR, $plugin_id, 4); $form_helper = new ClComponentForm($component_name, $container->get('cl_block.form_generator'), $container->get('plugin.manager.cl_component')); $form_helper = new ClComponentForm( $component_name, $container->get('cl_block.form_generator'), $container->get(NoThemeComponentManager::class) ); return new static( $configuration, $plugin_id, Loading