protected function ErlLayout::getSelectOptions in Entity Reference with Layout 8
Convert textarea lines into an array.
Parameters
string $string: The textarea lines to explode.
bool $summary: A flag to return a formatted list of classes available.
Return value
array An array keyed by the classes.
1 call to ErlLayout::getSelectOptions()
- ErlLayout::processConfigurationForm in modules/
erl_layouts/ src/ Plugin/ Layout/ ErlLayout.php - Add the options.
File
- modules/
erl_layouts/ src/ Plugin/ Layout/ ErlLayout.php, line 284
Class
- ErlLayout
- Layout class with various formatting options for custom ERL layouts.
Namespace
Drupal\erl_layouts\Plugin\LayoutCode
protected function getSelectOptions($string, $summary = FALSE) {
$options = [];
$lines = preg_split("/\\r\\n|\\r|\\n/", trim($string));
$lines = array_filter($lines);
foreach ($lines as $line) {
list($class, $label) = explode('|', trim($line));
$label = $label ?: $class;
$options[$class] = $label;
}
if ($summary) {
return implode(', ', array_keys($options));
}
return $options;
}