You are here

public function UnboundDisplay::generateDisplay in Layout 8.2

Implements UnboundDisplayInterface::generateDisplay().

Throws

\Exception

Overrides UnboundDisplayInterface::generateDisplay

File

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

Class

UnboundDisplay
Defines the unbound_display entity.

Namespace

Drupal\layout\Entity

Code

public function generateDisplay(LayoutInterface $layout, $id, $entity_type = 'display') {
  $values = array(
    'layout' => $layout
      ->getPluginId(),
    'blockInfo' => $this
      ->mapBlocksToLayout($layout),
    'id' => $id,
  );
  $entity = entity_create($entity_type, $values);
  if (!$entity instanceof BoundDisplayInterface) {
    throw new \Exception(sprintf('Attempted to bind an unbound display but provided an invalid entity type.'), E_RECOVERABLE_ERROR);
  }
  return $entity;
}