3

The Drupal Examples "entity" project was really helpful for me when I was learning the entity API in Drupal 7. I have seen no explanation though for why this doesn't exist in Drupal 8 or why it was renamed, etc.

  • 3
    Acquia have a good short version here: dev.acquia.com/blog/… (under "Entities, entities, everywhere!"). Does that help or maybe bring up more questions? – Clive Dec 22 '15 at 21:23
  • 1
    That is a huge help, Clive. I'll leave the question open for a while in case anyone else has something to add, but I think the answer is probably at this link. – HaleFx Dec 22 '15 at 21:39
  • 2
    That's a good idea, that article is from well over a year ago so there's probably a good amount to be added – Clive Dec 22 '15 at 21:43
3

I'm not sure what you are asking.

Example modules are named after what they're an example of, it's not for them to pick a name, really.

Drupal 8 has Content Entities, which evolved from the field structure of Drupal 7's entities and Config Entities, which are based on concepts from ctools exportables, entity.module's exportable entities and various other things.

Both share the same base class and a few comments and concepts but beyond that, they're quite different. Both are typed classes, Content entities have a strict although somewhat complex structure but are very extensible within that structure (That is, Entity -> Field Item List > Field Item > Property). They can have revisions and translations which are conceptually similar to field translations in 7.x but have a different API.

While there isn't that much documentation yet, https://www.drupal.org/developing/api/entity has some, there are also plenty of presentions from DrupalCons and other events about the concepts, API's and so on, including a recent one that I co-presented: https://2015.drupalcamp.at/session/entities-drupal-8.

3

Entities were a key new feature and concept in Drupal 7, abstracting the ability to add fields to other types of content than just nodes, such as users and taxonomy terms. However, the Drupal 7 core API was severely limited, and required use of modules like the Entity API module to further flesh out basic functionality, such as saving and deleting.

In Drupal 8, the Entity API has been completely re-hauled to not only fill the gaps in functionality from Drupal 7, but also to greatly improve developer experience. All entities are now classed objects that implement a standard EntityInterface (no more guessing which of the 100 entity hooks you're required to implement!), with baked-in knowledge about the active language. Compare and contrast:

<?php
# Drupal 7 code. 
$node->title $node->body[$langcode][0]['value']

# Drupal 8 code. 
$node->get('title')->value
$node->get('body')->value
 ?> 

Nearly anything you can create more than one of has been converted to an entity, bringing much greater consistency to Drupal development overall. There are two kinds: Config entities and Content entities. What's the difference?

Content Entities

  • Can customize fields
  • Stored in database tables (by default)
  • Mostly created on front-end

Examples

  • Nodes

  • Custom Blocks

  • Users Comments

  • Taxonomy Terms

  • Menu Links Aggregator

  • Feeds/Items

Config Entities

  • Can deploy to different environments
  • Stored in configuration system
  • Mostly created on back-end

Examples

  • Content Types
  • Custom Block
  • Types User Roles
  • Views Taxonomy
  • Vocabularies
  • Menus Image Styles

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.