Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

With the introduction of configuration entities, EntityInterface now has two child interfaces:

  • ContentEntityInterface
  • ConfigEntityInterface

Content entity classes should extend the Entity base class, and their entity type interface should implement ContentEntityInterface, for example:

<?php
namespace Drupal\comment\Plugin\Core\Entity;
use
Drupal\comment\CommentInterface;
use
Drupal\Core\Entity\Entity;
class
Comment extends Entity implements CommentInterface {}
?>

<?php
namespace Drupal\comment;
use
Drupal\Core\Entity\ContentEntityInterface;
interface
CommentInterface extends ContentEntityInterface {}
?>

ContentEntityInterface does not currently define any methods on its own, but it can be extended to provide content-specific functionality.

The following core entity type interfaces extend ContentEntityInterface:

  • FeedInterface (aggregator)
  • ItemInterface (aggregator)
  • CustomBlockInterface
  • CommentInterface
  • FileInterface
  • MenuLinkInterface
  • NodeInterface
  • TermInterface

Since user accounts are not content, User extends entity without implementing the ContentEntityInterface:

<?php
namespace Drupal\user\Plugin\Core\Entity;
use
Drupal\Core\Entity\Entity;
use
Drupal\user\UserInterface;
class
User extends Entity implements UserInterface {}
?>

<?php
namespace Drupal\user;
use
Drupal\Core\Entity\EntityInterface;
interface
UserInterface extends EntityInterface {}
?>

Note that configuration entity classes implement ConfigEntityInterface instead of ContentEntityInterface:

<?php
namespace Drupal\Core\Config\Entity;
use
Drupal\Core\Entity\Entity;
abstract class
ConfigEntityBase extends Entity implements ConfigEntityInterface {}
?>

When defining a new entity class, decide whether the entity should be stored as content (like nodes), configuration (like node types), or neither (like users).

Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done