public EntityType::__construct($definition)
Constructs a new EntityType.
Parameters
array $definition: An array of values from the annotation.
Throws
\Drupal\Core\Entity\Exception\EntityTypeIdLengthException Thrown when attempting to instantiate an entity type with too long ID.
File
- core/lib/Drupal/Core/Entity/EntityType.php, line 278
Class
- EntityType
- Provides an implementation of an entity type and its metadata.
Namespace
Drupal\Core\Entity
Code
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']; } }
Please login to continue.