public function EntityDisplayBase::createCopy

Creates a duplicate of the EntityDisplay object on a different view mode.

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

Parameters

$view_mode: The view mode for the new object.

Return value

\Drupal\entity\Plugin\Core\Entity\EntityDisplay The new object.

Overrides EntityDisplayBaseInterface::createCopy

File

drupal/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php, line 154
Contains \Drupal\entity\EntityDisplayBase.

Class

EntityDisplayBase
Base class for config entity types that store configuration for entity forms and displays.

Namespace

Drupal\entity

Code

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