You are here

public function EntityDisplayBase::__construct in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/EntityDisplayBase.php \Drupal\Core\Entity\EntityDisplayBase::__construct()

Constructs an Entity object.

Parameters

array $values: An array of values to set, keyed by property name. If the entity type has bundles, the bundle key has to be specified.

string $entity_type: The type of the entity to create.

Overrides ConfigEntityBase::__construct

3 calls to EntityDisplayBase::__construct()
EntityDisplayBase::__wakeup in core/lib/Drupal/Core/Entity/EntityDisplayBase.php
EntityFormDisplay::__construct in core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
Constructs an Entity object.
EntityViewDisplay::__construct in core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php
Constructs an Entity object.
2 methods override EntityDisplayBase::__construct()
EntityFormDisplay::__construct in core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
Constructs an Entity object.
EntityViewDisplay::__construct in core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php
Constructs an Entity object.

File

core/lib/Drupal/Core/Entity/EntityDisplayBase.php, line 125
Contains \Drupal\Core\Entity\EntityDisplayBase.

Class

EntityDisplayBase
Provides a common base class for entity view and form displays.

Namespace

Drupal\Core\Entity

Code

public function __construct(array $values, $entity_type) {
  if (!isset($values['targetEntityType']) || !isset($values['bundle'])) {
    throw new \InvalidArgumentException('Missing required properties for an EntityDisplay entity.');
  }
  if (!$this
    ->entityManager()
    ->getDefinition($values['targetEntityType'])
    ->isSubclassOf('\\Drupal\\Core\\Entity\\FieldableEntityInterface')) {
    throw new \InvalidArgumentException('EntityDisplay entities can only handle fieldable entity types.');
  }
  $this->renderer = \Drupal::service('renderer');

  // A plugin manager and a context type needs to be set by extending classes.
  if (!isset($this->pluginManager)) {
    throw new \RuntimeException('Missing plugin manager.');
  }
  if (!isset($this->displayContext)) {
    throw new \RuntimeException('Missing display context type.');
  }
  parent::__construct($values, $entity_type);
  $this->originalMode = $this->mode;
  $this
    ->init();
}