- Issue created by @zengenuity
- πΊπΈUnited States zengenuity
For anyone else looking for this, I figured out how to do it with that event. Here's the important part of my subscriber.
<?php /** * {@inheritDoc} */ public static function getSubscribedEvents() { // Run this with low priority so that other subscribers can add their templates first. return [ LayoutParagraphsAllowedTypesEvent::EVENT_NAME => ['filterTemplates', -100], ]; } /** * Filter templates to the allowed types. * * @param \Drupal\layout_paragraphs\Event\LayoutParagraphsAllowedTypesEvent $event * The allowed types event. */ public function filterTemplates(LayoutParagraphsAllowedTypesEvent $event) { $template_types = $event->getTypes(); if (($layout = $event->getLayout()) && ($entity = $layout->getEntity())) { $entity_type = $entity->getEntityTypeId(); $bundle = $entity->bundle(); // Your logic here to remove items from $template_types $event->setTypes($template_types); } } ?>
- Status changed to Closed: works as designed
4 months ago 6:23pm 24 July 2024