You are here

protected function LayoutParagraphsWidget::getAvailableLayoutsByType in Layout Paragraphs 1.0.x

Returns an array of available layouts for a given paragraph type.

Parameters

\Drupal\paragraphs\ParagraphsTypeInterface $paragraphs_type: The paragraph entity.

Return value

array An array of available layout plugins.

3 calls to LayoutParagraphsWidget::getAvailableLayoutsByType()
LayoutParagraphsWidget::formMultipleElements in src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php
Builds the main widget form array container/wrapper.
LayoutParagraphsWidget::getAvailableLayouts in src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php
Returns an array of available layouts for a given paragraph.
LayoutParagraphsWidget::settingsSummary in src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php
Returns a short summary for the current widget settings.

File

src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php, line 2221

Class

LayoutParagraphsWidget
Entity Reference with Layout field widget.

Namespace

Drupal\layout_paragraphs\Plugin\Field\FieldWidget

Code

protected function getAvailableLayoutsByType(ParagraphsTypeInterface $paragraphs_type) {
  $plugins = $paragraphs_type
    ->getEnabledBehaviorPlugins();
  if (isset($plugins['layout_paragraphs'])) {
    $layout_paragraphs_plugin = $paragraphs_type
      ->getBehaviorPlugin('layout_paragraphs');
    $config = $layout_paragraphs_plugin
      ->getConfiguration();
    return $config['available_layouts'] ?? [];
  }
  return [];
}