public function BlazyAdminFormatterBase::getSettingsSummary in Blazy 7
Same name and namespace in other branches
- 8.2 src/Form/BlazyAdminFormatterBase.php \Drupal\blazy\Form\BlazyAdminFormatterBase::getSettingsSummary()
- 8 src/Form/BlazyAdminFormatterBase.php \Drupal\blazy\Form\BlazyAdminFormatterBase::getSettingsSummary()
Return the field formatter settings summary.
File
- src/
Form/ BlazyAdminFormatterBase.php, line 58
Class
- BlazyAdminFormatterBase
- A base for field formatter admin to have re-usable methods in one place.
Namespace
Drupal\blazy\FormCode
public function getSettingsSummary($definition = []) {
$summary = [];
if (empty($definition['settings'])) {
return $summary;
}
$this
->getExcludedSettingsSummary($definition);
$enforced = [
'optionset',
'cache',
'skin',
'view_mode',
'override',
'overridables',
'style',
'vanilla',
];
$enforced = isset($definition['enforced']) ? $definition['enforced'] : $enforced;
$settings = array_filter($definition['settings']);
$breakpoints = isset($settings['breakpoints']) && is_array($settings['breakpoints']) ? array_filter($settings['breakpoints']) : [];
foreach ($definition['settings'] as $key => $setting) {
$title = ucfirst(str_replace('_', ' ', $key));
$vanilla = !empty($settings['vanilla']);
if ($key == 'breakpoints') {
$widths = [];
if ($breakpoints) {
foreach ($breakpoints as $breakpoint) {
if (!empty($breakpoint['width'])) {
$widths[] = $breakpoint['width'];
}
}
}
$title = 'Breakpoints';
$setting = $widths ? implode(', ', $widths) : 'none';
}
else {
if ($vanilla && !in_array($key, $enforced)) {
continue;
}
if ($key == 'override' && empty($setting)) {
unset($settings['overridables']);
}
if (is_bool($setting) && $setting) {
$setting = 'yes';
}
elseif (is_array($setting)) {
$setting = array_filter($setting);
if (!empty($setting)) {
$setting = implode(', ', $setting);
}
}
if ($key == 'cache') {
$setting = $this
->getCacheOptions()[$setting];
}
}
if (empty($setting)) {
continue;
}
if (isset($settings[$key]) && is_string($setting)) {
$summary[] = t('@title: <strong>@setting</strong>', [
'@title' => $title,
'@setting' => $setting,
]);
}
}
return implode('<br />', $summary);
}