You are here

protected function InlineParagraphsWidget::getAccessibleOptions in Paragraphs 8

Returns the available paragraphs type.

Return value

array Available paragraphs types.

3 calls to InlineParagraphsWidget::getAccessibleOptions()
InlineParagraphsWidget::buildAddActions in src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
Add 'add more' button, if not working with a programmed form.
InlineParagraphsWidget::buildButtonsAddMode in src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
Builds dropdown button for adding new paragraph.
InlineParagraphsWidget::buildSelectAddMode in src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
Builds list of actions based on paragraphs type.

File

src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php, line 1003

Class

InlineParagraphsWidget
Plugin implementation of the 'entity_reference paragraphs' widget.

Namespace

Drupal\paragraphs\Plugin\Field\FieldWidget

Code

protected function getAccessibleOptions() {
  if ($this->accessOptions !== NULL) {
    return $this->accessOptions;
  }
  $entity_type_manager = \Drupal::entityTypeManager();
  $target_type = $this
    ->getFieldSetting('target_type');
  $bundles = $this
    ->getAllowedTypes();
  $access_control_handler = $entity_type_manager
    ->getAccessControlHandler($target_type);
  $dragdrop_settings = $this
    ->getSelectionHandlerSetting('target_bundles_drag_drop');
  $this->accessOptions = [];
  foreach ($bundles as $machine_name => $bundle) {
    if ($dragdrop_settings || (empty($this
      ->getSelectionHandlerSetting('target_bundles')) || in_array($machine_name, $this
      ->getSelectionHandlerSetting('target_bundles')))) {
      if ($access_control_handler
        ->createAccess($machine_name)) {
        $this->accessOptions[$machine_name] = $bundle['label'];
      }
    }
  }
  return $this->accessOptions;
}