March 2019
Intermediate to advanced
580 pages
15h 3m
English
As we saw in the previous chapter, when looking at the Node and NodeType entity types, entity type definitions belong inside the Entity folder of our module's namespace. In there, we will create a class called Product, which will have an annotation at the top to tell Drupal this is a content entity type. This is the most important part in defining a new entity type:
namespace Drupal\products\Entity;use Drupal\Core\Entity\ContentEntityBase;/** * Defines the Product entity. * * @ContentEntityType( * id = "product", * label = @Translation("Product"), * handlers = { * "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", * "list_builder" = "Drupal\products\ProductListBuilder", * * "form" = { * "default" = "Drupal\products\Form\ProductForm", ...