public EntityType::__construct($definition)
Constructs a new EntityType.
array $definition: An array of values from the annotation.
\Drupal\Core\Entity\Exception\EntityTypeIdLengthException Thrown when attempting to instantiate an entity type with too long ID.
public function __construct($definition) { // Throw an exception if the entity type ID is longer than 32 characters. if (Unicode::strlen($definition['id']) > static::ID_MAX_LENGTH) { throw new EntityTypeIdLengthException('Attempt to create an entity type with an ID longer than ' . static::ID_MAX_LENGTH . " characters: {$definition['id']}."); } foreach ($definition as $property => $value) { $this->set($property, $value); } // Ensure defaults. $this->entity_keys += array( 'revision' => '', 'bundle' => '', 'langcode' => '', 'default_langcode' => 'default_langcode', ); $this->handlers += array( 'access' => 'Drupal\Core\Entity\EntityAccessControlHandler', ); if (isset($this->handlers['storage'])) { $this->checkStorageClass($this->handlers['storage']); } // Automatically add the EntityChanged constraint if the entity type tracks // the changed time. if ($this->isSubclassOf('Drupal\Core\Entity\EntityChangedInterface')) { $this->addConstraint('EntityChanged'); } // Ensure a default list cache tag is set. if (empty($this->list_cache_tags)) { $this->list_cache_tags = [$definition['id'] . '_list']; } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!EntityType.php/function/EntityType::__construct/8.1.x