public EntityDisplayBase::__construct(array $values, $entity_type)
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
File
- core/lib/Drupal/Core/Entity/EntityDisplayBase.php, line 120
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(); }
Please login to continue.