You are here

public function Block::createDuplicateBlock in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/block/src/Entity/Block.php \Drupal\block\Entity\Block::createDuplicateBlock()

Creates a duplicate of the block entity.

Parameters

string $new_id: (optional) The new ID on the duplicate block.

string $new_theme: (optional) The theme on the duplicate block.

Return value

static A clone of $this with all identifiers unset, so saving it inserts a new entity into the storage system.

Overrides BlockInterface::createDuplicateBlock

File

core/modules/block/src/Entity/Block.php, line 325
Contains \Drupal\block\Entity\Block.

Class

Block
Defines a Block configuration entity class.

Namespace

Drupal\block\Entity

Code

public function createDuplicateBlock($new_id = NULL, $new_theme = NULL) {
  $duplicate = parent::createDuplicate();
  if (!empty($new_id)) {
    $duplicate->id = $new_id;
  }
  if (!empty($new_theme)) {
    $duplicate->theme = $new_theme;
  }
  return $duplicate;
}