You are here

public function LayoutParagraphsUpdateLayoutSubscriber::compareLayouts in Layout Paragraphs 2.0.x

Restricts available types based on settings in layout.

Parameters

\Drupal\layout_paragraphs\Event\LayoutParagraphsUpdateLayoutEvent $event: The allowed types event.

File

src/EventSubscriber/LayoutParagraphsUpdateLayoutSubscriber.php, line 28

Class

LayoutParagraphsUpdateLayoutSubscriber
Event subscriber.

Namespace

Drupal\layout_paragraphs\EventSubscriber

Code

public function compareLayouts(LayoutParagraphsUpdateLayoutEvent $event) {
  $original = $event
    ->getOriginalLayout()
    ->getParagraphsReferenceField();
  $layout = $event
    ->getUpdatedLayout()
    ->getParagraphsReferenceField();
  $event->needsRefresh = $original
    ->isEmpty() != $layout
    ->isEmpty();
}