You are here

public function Display::generateUnboundDisplay in Layout 8.2

Implements BoundDisplayInterface::generateUnboundDisplay().

Throws

\Exception

Overrides BoundDisplayInterface::generateUnboundDisplay

File

lib/Drupal/layout/Entity/Display.php, line 152
Definition of Drupal\layout\Entity\Display.

Class

Display
Defines the display entity.

Namespace

Drupal\layout\Entity

Code

public function generateUnboundDisplay($id, $entity_type = 'unbound_display') {
  $block_info = $this
    ->getAllBlockInfo();
  foreach ($block_info as &$info) {
    unset($info['region']);
  }
  $values = array(
    'blockInfo' => $block_info,
    'id' => $id,
  );
  $entity = entity_create($entity_type, $values);
  if (!$entity instanceof UnboundDisplayInterface) {
    throw new \Exception(sprintf('Attempted to create an unbound display using an invalid entity type.'), E_RECOVERABLE_ERROR);
  }
  return $entity;
}