class PanelizerWidget in Lightning Layout 8
A Panelizer field widget plugin that supports view mode descriptions.
Hierarchy
- class \Drupal\lightning_layout\Plugin\Field\FieldWidget\PanelizerWidget extends \Drupal\panelizer\Plugin\Field\FieldWidget\PanelizerWidget
Expanded class hierarchy of PanelizerWidget
1 file declares its use of PanelizerWidget
- lightning_layout.module in ./
lightning_layout.module - Contains layout functionality for Lightning.
File
- src/
Plugin/ Field/ FieldWidget/ PanelizerWidget.php, line 14
Namespace
Drupal\lightning_layout\Plugin\Field\FieldWidgetView source
class PanelizerWidget extends BaseWidget {
/**
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element = parent::formElement($items, $delta, $element, $form, $form_state);
foreach (Element::children($element) as $i) {
$item =& $element[$i];
// If the item is associated with a view mode, display the view mode
// description if no description is set already.
if ($item['view_mode']['#value'] && empty($item['default']['#description'])) {
$view_mode = $items
->getEntity()
->getEntityTypeId() . '.' . $item['view_mode']['#value'];
if ($view_mode = EntityViewMode::load($view_mode)) {
$element[$i]['default']['#description'] = $view_mode
->getThirdPartySetting('lightning_core', 'description');
}
}
}
return $element;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PanelizerWidget:: |
public | function |