public function UnboundDisplay::generateDisplay

Implements UnboundDisplayInterface::generateDisplay().

Throws

\Exception

Overrides UnboundDisplayInterface::generateDisplay

File

drupal/core/modules/layout/lib/Drupal/layout/Plugin/Core/Entity/UnboundDisplay.php, line 44
Definition of Drupal\layout\Plugin\Core\Entity\Display.

Class

UnboundDisplay
Defines the unbound_display entity.

Namespace

Drupal\layout\Plugin\Core\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;
}