21 янв. 2021 г.

Drupal 8. Entity API




Entity types in core come in two variants. Content & Config

 The Entity System is the API for entities manipulation (CRUD: create, read, update, delete). Entity validation has its own API (which could validate an Entity saved via REST, rather than a form, for example).

Entities are typed classes with methods


Configuration Entity
Used by the Configuration System. Supports translations and can provide custom defaults for installations. Configuration entities are stored within the common config database table as rows.
Content Entity
Consist of configurable and base fields, and can have revisions and support translations. Content entities are stored within a custom database table as rows. The table name is the same as the content entity "id", and the columns are defined by the entity's "baseFieldDefinitions" method.

Охватывает методы API общего объекта

  • Entity::create()
  • Entity::load()
  • Entity::save()
  • Entity::id()
  • Entity::bundle()
  • Entity::isNew()
  • Entity::label()


В Drupal 8 бандлы представляют собой тип контейнера для информации, которая содержит определения полей или настроек.



Annotations

Annotations are read and parsed at runtime by an annotation engine. Drupal 8 uses the Doctrine annotation parser, which turns it into an object that PHP can use.