public function ViewModeSelectorSelect::__construct in Opigno certificate 8
Same name and namespace in other branches
- 3.x src/Plugin/Field/FieldWidget/ViewModeSelectorSelect.php \Drupal\opigno_certificate\Plugin\Field\FieldWidget\ViewModeSelectorSelect::__construct()
Gather all available view modes.
Overrides ViewModeSelectorWidgetBase::__construct
File
- src/
Plugin/ Field/ FieldWidget/ ViewModeSelectorSelect.php, line 26
Class
- ViewModeSelectorSelect
- Class ViewModeSelectorSelect.
Namespace
Drupal\opigno_certificate\Plugin\Field\FieldWidgetCode
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, EntityDisplayRepository $entity_display_repository) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings, $entity_display_repository);
// Get all view modes without restricting them to enabled ones..
// Workaround for static caching issue with display modes.
$entity_type = $field_definition
->getTargetEntityTypeId();
$view_modes = $entity_display_repository
->getViewModeOptions($entity_type);
// Don't infinitely recurse.
unset($view_modes['view_mode_selector']);
$this->viewModes = $view_modes;
}