function LayoutBuilderEntityViewDisplayForm::hasOverrides

Same name in other branches
  1. 8.9.x core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php \Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm::hasOverrides()
  2. 10 core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php \Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm::hasOverrides()
  3. 11.x 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()
        ->accessCheck(FALSE)
        ->exists(OverridesSectionStorage::FIELD_NAME);
    if ($bundle_key = $entity_type->getKey('bundle')) {
        $query->condition($bundle_key, $display->getTargetBundle());
    }
    return (bool) $query->count()
        ->execute();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.