vendor/ibexa/connect/src/bundle/EventSubscriber/BlockDefinitionEventSubscriber.php line 26

Open in your IDE?
  1. <?php
  2. /**
  3. * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4. * @license For full copyright and license information view LICENSE file distributed with this source code.
  5. */
  6. declare(strict_types=1);
  7. namespace Ibexa\Bundle\Connect\EventSubscriber;
  8. use Ibexa\Contracts\FieldTypePage\FieldType\Page\Block\Definition\BlockDefinitionEvents;
  9. use Ibexa\FieldTypePage\FieldType\Page\Block\Definition\Event\BlockDefinitionEvent;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. final class BlockDefinitionEventSubscriber implements EventSubscriberInterface
  12. {
  13. public static function getSubscribedEvents(): array
  14. {
  15. return [
  16. BlockDefinitionEvents::getBlockDefinitionEventName(
  17. PageBuilderPreRenderEventSubscriber::IBEXA_CONNECT_BLOCK
  18. ) => ['onBlockDefinition', -10],
  19. ];
  20. }
  21. public function onBlockDefinition(BlockDefinitionEvent $event): void
  22. {
  23. $definition = $event->getDefinition();
  24. if (!empty($definition->getViews())) {
  25. return;
  26. }
  27. // Ibexa Connect block doesn't provide default templates and the block is unusable
  28. // unless it's properly configured to reflect client specific Connect configuration.
  29. $definition->setVisible(false);
  30. }
  31. }