Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/EntityDisplayBase.php \Drupal\Core\Entity\EntityDisplayBase::createCopy()
  2. 9 core/lib/Drupal/Core/Entity/EntityDisplayBase.php \Drupal\Core\Entity\EntityDisplayBase::createCopy()

Creates a duplicate of the entity display object on a different view mode.

The new object necessarily has the same $targetEntityType and $bundle properties than the original one.

Parameters

string $view_mode: The view mode for the new object.

Return value

static A duplicate of this object with the given view mode.

Overrides EntityDisplayInterface::createCopy

1 call to EntityDisplayBase::createCopy()
LayoutBuilderEntityViewDisplay::createCopy in core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
Creates a duplicate of the entity display object on a different view mode.
1 method overrides EntityDisplayBase::createCopy()
LayoutBuilderEntityViewDisplay::createCopy in core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
Creates a duplicate of the entity display object on a different view mode.

File

core/lib/Drupal/Core/Entity/EntityDisplayBase.php, line 325

Class

EntityDisplayBase
Provides a common base class for entity view and form displays.

Namespace

Drupal\Core\Entity

Code

public function createCopy($mode) {
  $display = $this
    ->createDuplicate();
  $display->mode = $display->originalMode = $mode;
  return $display;
}