public function Contextual::formatterViewElementsAlter in Custom Formatters 8.3
File
- src/
Plugin/ CustomFormatters/ FormatterExtras/ Contextual.php, line 56
Class
- Contextual
- Contextual links optional integration plugin.
Namespace
Drupal\custom_formatters\Plugin\CustomFormatters\FormatterExtrasCode
public function formatterViewElementsAlter(array &$element) {
if ($this->entity
->getThirdPartySetting('contextual', 'mode', CUSTOM_FORMATTERS_EXTRAS_CONTEXTUAL_ENABLED) == CUSTOM_FORMATTERS_EXTRAS_CONTEXTUAL_ENABLED) {
$element[0] = [
'markup' => $element[0],
];
$element[0]['contextual_links'] = [
'#type' => 'contextual_links_placeholder',
'#id' => _contextual_links_to_id([
'custom_formatters' => [
'route_parameters' => [
'formatter' => $this->entity
->id(),
],
],
]),
];
$element['#attributes']['class'][] = 'contextual-region';
}
}