Returns select options for a plugin setting.
This is done to allow \Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget::settingsSummary() to access option labels. Not all plugin setting are available.
string $setting_name: The name of the widget setting. Supported settings:
array|null An array of setting option usable as a value for a "#options" key.
protected function getSettingOptions($setting_name) {
switch ($setting_name) {
case 'edit_mode':
$options = [
'open' => $this
->t('Open'),
'closed' => $this
->t('Closed'),
'closed_expand_nested' => $this
->t('Closed, show nested'),
];
break;
case 'closed_mode':
$options = [
'summary' => $this
->t('Summary'),
'preview' => $this
->t('Preview'),
];
break;
case 'autocollapse':
$options = [
'none' => $this
->t('None'),
'all' => $this
->t('All'),
];
break;
case 'add_mode':
$options = [
'select' => $this
->t('Select list'),
'button' => $this
->t('Buttons'),
'dropdown' => $this
->t('Dropdown button'),
'modal' => $this
->t('Modal form'),
];
break;
case 'features':
$options = [
'duplicate' => $this
->t('Duplicate'),
'collapse_edit_all' => $this
->t('Collapse / Edit all'),
// The "Add above" feature will be completely injected clientside,
// whenever this option is enabled in the widget configuration.
// @see Drupal.behaviors.paragraphsAddAboveButton
'add_above' => $this
->t('Add above'),
'convert' => $this
->t('Convert'),
];
break;
}
return isset($options) ? $options : NULL;
}