function Block::createDuplicateBlock

Same name and namespace in other branches
  1. 11.x core/modules/block/src/Entity/Block.php \Drupal\block\Entity\Block::createDuplicateBlock()
  2. 10 core/modules/block/src/Entity/Block.php \Drupal\block\Entity\Block::createDuplicateBlock()
  3. 8.9.x core/modules/block/src/Entity/Block.php \Drupal\block\Entity\Block::createDuplicateBlock()

File

core/modules/block/src/Entity/Block.php, line 329

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;
}

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