class LayoutParagraphsUpdateLayoutSubscriber in Layout Paragraphs 2.0.x
Event subscriber.
Hierarchy
- class \Drupal\layout_paragraphs\EventSubscriber\LayoutParagraphsUpdateLayoutSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of LayoutParagraphsUpdateLayoutSubscriber
1 string reference to 'LayoutParagraphsUpdateLayoutSubscriber'
1 service uses LayoutParagraphsUpdateLayoutSubscriber
File
- src/
EventSubscriber/ LayoutParagraphsUpdateLayoutSubscriber.php, line 11
Namespace
Drupal\layout_paragraphs\EventSubscriberView source
class LayoutParagraphsUpdateLayoutSubscriber implements EventSubscriberInterface {
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents() {
return [
LayoutParagraphsUpdateLayoutEvent::EVENT_NAME => 'compareLayouts',
];
}
/**
* Restricts available types based on settings in layout.
*
* @param \Drupal\layout_paragraphs\Event\LayoutParagraphsUpdateLayoutEvent $event
* The allowed types event.
*/
public function compareLayouts(LayoutParagraphsUpdateLayoutEvent $event) {
$original = $event
->getOriginalLayout()
->getParagraphsReferenceField();
$layout = $event
->getUpdatedLayout()
->getParagraphsReferenceField();
$event->needsRefresh = $original
->isEmpty() != $layout
->isEmpty();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LayoutParagraphsUpdateLayoutSubscriber:: |
public | function | Restricts available types based on settings in layout. | |
LayoutParagraphsUpdateLayoutSubscriber:: |
public static | function |