protected function ParagraphsStylePlugin::getStyleOptions

Gets sorted style titles keyed by their names belonging to the given group.

If an empty string is given, returns all styles.

Parameters

string $group: (optional) The style group. Defaults to empty string.

string $default_style_key: (optional) Default style key will be displayed first.

bool $access_check: (optional) Whether we should check the style access. Defaults to false.

Return value

array An array of style titles keyed by the respective style machine names.

1 call to ParagraphsStylePlugin::getStyleOptions()
ParagraphsStylePlugin::buildBehaviorForm in paragraphs_collection/src/Plugin/paragraphs/Behavior/ParagraphsStylePlugin.php
Builds a behavior perspective for each paragraph based on its type.

File

paragraphs_collection/src/Plugin/paragraphs/Behavior/ParagraphsStylePlugin.php, line 168

Class

ParagraphsStylePlugin
Provides style selection plugin.

Namespace

Drupal\paragraphs_collection\Plugin\paragraphs\Behavior

Code

protected function getStyleOptions($group = '', $default_style_key = '', $access_check = FALSE) {
  $styles = $this->yamlStyleDiscovery
    ->getStyleOptions($group, $access_check);
  if (isset($styles[$default_style_key])) {

    // Show default selection as a first option in the list with dashes.
    return [
      $default_style_key => $this
        ->t('- @name -', [
        '@name' => $styles[$default_style_key],
      ]),
    ] + $styles;
  }
  return $styles;
}