Gets sorted style titles keyed by their names belonging to the given group.
If an empty string is given, returns all styles.
string $group: (optional) The style group. Defaults to empty string.
bool $access_check: (optional) Whether we should check the style access. Defaults to false.
array An array of style titles keyed by the respective style machine names.
Overrides StyleDiscoveryInterface::getStyleOptions
public function getStyleOptions($group = '', $access_check = FALSE) {
$options = [];
$style_collection = $this
->getStyles();
$enabled_styles = $this->configFactory
->get('paragraphs_collection.settings')
->get('enabled_styles');
foreach ($style_collection as $style => $definition) {
if (empty($enabled_styles) || in_array($style, $enabled_styles)) {
if (empty($group) || in_array($group, $definition['groups'])) {
// Filter the styles based on whether the current user has access.
if ($access_check && !$this
->isAllowedAccess($definition)) {
continue;
}
$options[$style] = $definition['title'];
}
}
}
uasort($options, 'strcasecmp');
return $options;
}