private function ForwardForm::isValidDisplay in Forward 8
Same name and namespace in other branches
- 8.3 src/Form/ForwardForm.php \Drupal\forward\Form\ForwardForm::isValidDisplay()
- 8.2 src/Form/ForwardForm.php \Drupal\forward\Form\ForwardForm::isValidDisplay()
- 4.x src/Form/ForwardForm.php \Drupal\forward\Form\ForwardForm::isValidDisplay()
- 4.0.x src/Form/ForwardForm.php \Drupal\forward\Form\ForwardForm::isValidDisplay()
Determine if a given display is valid for an entity
1 call to ForwardForm::isValidDisplay()
- ForwardForm::submitForm in src/
Form/ ForwardForm.php - Form submission handler.
File
- src/
Form/ ForwardForm.php, line 239
Class
- ForwardForm
- Forward a page to a friend
Namespace
Drupal\forward\FormCode
private function isValidDisplay(EntityInterface $entity, $view_mode) {
// Assume the display is valid
$valid = TRUE;
// Build display name
if ($entity
->getEntityType()
->hasKey('bundle')) {
// Bundled entity types, e.g. node
$display_name = $entity
->getEntityTypeId() . '.' . $entity
->bundle() . '.' . $view_mode;
}
else {
// Entity types without bundles, e.g. user
$display_name = $entity
->getEntityTypeId() . '.' . $view_mode;
}
// Attempt load
$display = $this->entityTypeManager
->getStorage('entity_view_display')
->load($display_name);
if ($display) {
// If the display loads, it exists in configuration, and status can be checked
$valid = FALSE;
if ($display
->status()) {
$valid = TRUE;
}
}
return $valid;
}