You are here

protected function ParagraphsWidget::getAccessibleOptions in Paragraphs 8

Returns the available paragraphs type.

Return value

array Available paragraphs types.

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

File

src/Plugin/Field/FieldWidget/ParagraphsWidget.php, line 1442

Class

ParagraphsWidget
Plugin implementation of the 'entity_reference_revisions paragraphs' widget.

Namespace

Drupal\paragraphs\Plugin\Field\FieldWidget

Code

protected function getAccessibleOptions() {
  if ($this->accessOptions !== NULL) {
    return $this->accessOptions;
  }
  $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');
  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;
}