diff --git a/src/Plugin/paragraphs/Behavior/GridstackContainer.php b/src/Plugin/paragraphs/Behavior/GridstackContainer.php index 2402add87327f7e0b59a2f5db06c2bb575f19130..cb08800d5f5aa980aef721b7867d513052bdb8c5 100644 --- a/src/Plugin/paragraphs/Behavior/GridstackContainer.php +++ b/src/Plugin/paragraphs/Behavior/GridstackContainer.php @@ -14,9 +14,11 @@ use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\paragraphs\Annotation\ParagraphsBehavior; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; +use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\paragraphs_gridstack\ParagraphsGridstackManagerInterface; use Drupal\paragraphs_gridstack\GridstackBreakpointsManagerInterface; +use Drupal\Core\Logger\LoggerChannelFactoryInterface; /** * Gridstack container behavior implementation. @@ -30,6 +32,13 @@ use Drupal\paragraphs_gridstack\GridstackBreakpointsManagerInterface; */ class GridstackContainer extends ParagraphsBehaviorBase implements ContainerFactoryPluginInterface { + /** + * The logger. + * + * @var \Psr\Log\LoggerInterface + */ + protected LoggerInterface $logger; + /** * The config factory. * @@ -68,13 +77,25 @@ class GridstackContainer extends ParagraphsBehaviorBase implements ContainerFact /** * GridstackContainer plugin constructor. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityFieldManagerInterface $entity_field_manager, ConfigFactoryInterface $container_factory, ParagraphsGridstackManagerInterface $gridstack_optionsets_manager, GridstackBreakpointsManagerInterface $gridstack_breakpoints_manager, LibraryDiscoveryInterface $library_discovery, ModuleHandlerInterface $module_handler) { + public function __construct( + array $configuration, + $plugin_id, + $plugin_definition, + EntityFieldManagerInterface $entity_field_manager, + ConfigFactoryInterface $container_factory, + ParagraphsGridstackManagerInterface $gridstack_optionsets_manager, + GridstackBreakpointsManagerInterface $gridstack_breakpoints_manager, + LibraryDiscoveryInterface $library_discovery, + ModuleHandlerInterface $module_handler, + LoggerChannelFactoryInterface $logger_factory + ) { parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_field_manager); $this->configFactory = $container_factory; $this->gridstackOptionsetsManager = $gridstack_optionsets_manager; $this->gridstackBreakpointsManager = $gridstack_breakpoints_manager; $this->libraryDiscovery = $library_discovery; $this->moduleHandler = $module_handler; + $this->logger = $logger_factory->get('paragraph_gridstack'); } /** @@ -91,6 +112,7 @@ class GridstackContainer extends ParagraphsBehaviorBase implements ContainerFact $container->get('paragraphs_gridstack.breakpoints_manager'), $container->get('library.discovery'), $container->get('module_handler'), + $container->get('logger.factory'), ); } @@ -290,14 +312,18 @@ class GridstackContainer extends ParagraphsBehaviorBase implements ContainerFact $libraries_providers = ['paragraphs_gridstack']; $this->moduleHandler->alter('gridstack_libraries_providers', $libraries_providers); - assert(!empty($libraries_providers), 'No libraries providers found for Gridstack.'); + if (empty($libraries_providers)) { + $this->logger->notice('No libraries providers found for Gridstack.'); + } foreach ($libraries_providers as $provider) { $libraries[] = $this->libraryDiscovery ->getLibrariesByExtension($provider); } - assert(!empty($libraries), 'No libraries found for Gridstack.'); + if (empty($libraries)) { + $this->logger->notice('No libraries found for Gridstack.'); + } $libraries = array_merge(...$libraries); foreach ($libraries as $machine_name => $properties) {