function EntityType::get

Same name in this branch
  1. main core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::get()
  2. main core/lib/Drupal/Core/Entity/Annotation/EntityType.php \Drupal\Core\Entity\Annotation\EntityType::get()
Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Entity/Attribute/EntityType.php \Drupal\Core\Entity\Attribute\EntityType::get()
  2. 11.x core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::get()
  3. 11.x core/lib/Drupal/Core/Entity/Annotation/EntityType.php \Drupal\Core\Entity\Annotation\EntityType::get()
  4. 10 core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::get()
  5. 10 core/lib/Drupal/Core/Entity/Annotation/EntityType.php \Drupal\Core\Entity\Annotation\EntityType::get()
  6. 9 core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::get()
  7. 9 core/lib/Drupal/Core/Entity/Annotation/EntityType.php \Drupal\Core\Entity\Annotation\EntityType::get()
  8. 8.9.x core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::get()
  9. 8.9.x core/lib/Drupal/Core/Entity/Annotation/EntityType.php \Drupal\Core\Entity\Annotation\EntityType::get()

Overrides AttributeBase::get

File

core/lib/Drupal/Core/Entity/Attribute/EntityType.php, line 78

Class

EntityType
Defines an entity type for plugin discovery.

Namespace

Drupal\Core\Entity\Attribute

Code

public function get() : array|object {
  // Use the specified entity type class, and remove it before instantiating.
  $class = $this->entity_type_class;
  $values = array_filter(get_object_vars($this) + [
    'class' => $this->getClass(),
    'provider' => $this->getProvider(),
  ], function ($value, $key) {
    return !($value === NULL && ($key === 'deriver' || $key === 'provider' || $key == 'entity_type_class'));
  }, ARRAY_FILTER_USE_BOTH);
  return new $class($values);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.