You are here

protected function LayoutBuilderEntityViewDisplayForm::hasOverrides in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php \Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm::hasOverrides()

Determines if the defaults have any overrides.

Parameters

\Drupal\layout_builder\Entity\LayoutEntityDisplayInterface $display: The entity display.

Return value

bool TRUE if there are any overrides of this default, FALSE otherwise.

1 call to LayoutBuilderEntityViewDisplayForm::hasOverrides()
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 166

Class

LayoutBuilderEntityViewDisplayForm
Edit form for the LayoutBuilderEntityViewDisplay entity type.

Namespace

Drupal\layout_builder\Form

Code

protected function hasOverrides(LayoutEntityDisplayInterface $display) {
  if (!$display
    ->isOverridable()) {
    return FALSE;
  }
  $entity_type = $this->entityTypeManager
    ->getDefinition($display
    ->getTargetEntityTypeId());
  $query = $this->entityTypeManager
    ->getStorage($display
    ->getTargetEntityTypeId())
    ->getQuery()
    ->exists(OverridesSectionStorage::FIELD_NAME);
  if ($bundle_key = $entity_type
    ->getKey('bundle')) {
    $query
      ->condition($bundle_key, $display
      ->getTargetBundle());
  }
  return (bool) $query
    ->count()
    ->execute();
}