1 layout.class.inc Layout::getClone()

Clone a layout and return new Layout object.

File

core/modules/layout/includes/layout.class.inc, line 479
Class for loading, modifying, and executing a layout.

Class

Layout
@file Class for loading, modifying, and executing a layout.

Code

function getClone() {
  $clone = clone($this);
  $clone->name = NULL;
  $clone->is_new = TRUE;
  $clone->module = NULL;
  $clone->storage = LAYOUT_STORAGE_NORMAL;

  // Copy over blocks with new UUIDs.
  $clone->content = array();
  $clone->positions = array();
  foreach ($this->positions as $region => $block_uuids) {
    foreach ($block_uuids as $block_uuid) {
      $new_block = $this->content[$block_uuid]->getClone();
      $clone->content[$new_block->uuid] = $new_block;
      $clone->positions[$region][] = $new_block->uuid;
    }
  }

  // Position the new layout one level above the current layout, assuming that
  // users will start with a generic layout, such as a global "node" layout,
  // then later create a more specific layout, such as "post nodes", which
  // should come before the more generic version.
  $clone->weight--;

  return $clone;
}