protected function LayoutBuilderEntityViewDisplayForm::isCanonicalMode in Drupal 8
Same name and namespace in other branches
- 9 core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php \Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm::isCanonicalMode()
Determines if the mode is used by the canonical route.
Parameters
string $mode: The view mode.
Return value
bool TRUE if the mode is valid, FALSE otherwise.
1 call to LayoutBuilderEntityViewDisplayForm::isCanonicalMode()
- LayoutBuilderEntityViewDisplayForm::form in core/
modules/ layout_builder/ src/ Form/ LayoutBuilderEntityViewDisplayForm.php - Gets the actual form array to be built.
File
- core/
modules/ layout_builder/ src/ Form/ LayoutBuilderEntityViewDisplayForm.php, line 135
Class
- LayoutBuilderEntityViewDisplayForm
- Edit form for the LayoutBuilderEntityViewDisplay entity type.
Namespace
Drupal\layout_builder\FormCode
protected function isCanonicalMode($mode) {
// @todo This is a convention core uses but is not a given, nor is it easily
// introspectable. Address in https://www.drupal.org/node/2907413.
$canonical_mode = 'full';
if ($mode === $canonical_mode) {
return TRUE;
}
// The default mode is valid if the canonical mode is not enabled.
if ($mode === 'default') {
$query = $this->entityTypeManager
->getStorage($this->entity
->getEntityTypeId())
->getQuery()
->condition('targetEntityType', $this->entity
->getTargetEntityTypeId())
->condition('bundle', $this->entity
->getTargetBundle())
->condition('status', TRUE)
->condition('mode', $canonical_mode);
return !$query
->count()
->execute();
}
return FALSE;
}