By andypost on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
The term controller is currently used inconsistently in Drupal 8 core. In particular, routing "controllers" and entity "controllers" are actually very different concepts. For this reason, the entity "controllers" will be referred to as handlers going forward, and the classes are being renamed as follows:
EntityRenderControllerrenamed toEntityViewBuilder
The annotation key has been renamed fromrendertoview_builder.EntityListControllerrenamed toEntityListBuilder
Note: There is an actual route controller named\Drupal\Core\Entity\Controller\EntityListControllerthat is not renamed. This is a great example for why this rename helps to understand the difference between those two classes.EntityStorageControllerInterfacerenamed toEntityStorageInterface
Also:- EntityStorageControllerBase => EntityStorageBase
- ConfigStorageController => ConfigEntityStorage
- FieldableEntityStorageControllerInterface => FieldableEntityStorageInterface
- FieldableEntityStorageControllerBase => ContentEntityStorageBase
- FieldableDatabaseStorageController => ContentEntityDatabaseStorage (later renamed to Sql\SqlContentEntityStorage)
EntityAccessControllerrenamed toEntityAccessControlHandlerEntityFormControllerrenamed toEntityForm
EntityManagerInterface::getFormController()is renamed toEntityManagerInterface::getFormObject()but that is almost never used directly, useEntityFormBuilder::getForm()(entity.form_builderservice) instead.EntityManager::getController()andEntityManager::hasController()renamed toEntityManager::getHandler()andEntityManager::hasHandler()
Note that all renames are accompanied by the corresponding renames of the methods on the EntityManager and EntityType classes.
A complete example:
/**
* @ContentEntityType(
* id = "user",
* label = @Translation("User"),
* handlers = {
* "storage" = "Drupal\user\UserStorage",
* "access" = "Drupal\user\UserAccessControlHandler",
* "list_builder" = "Drupal\user\UserListBuilder",
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "form" = {
* "default" = "Drupal\user\ProfileForm",
* "cancel" = "Drupal\user\Form\UserCancelForm",
* "register" = "Drupal\user\RegisterForm"
* },
* "translation" = "Drupal\user\ProfileTranslationHandler"
* },
* [...]
* )
*/
class User extends ContentEntityBase implements UserInterface { }
See also the documentation that is being written for entity handlers: https://drupal.org/node/2143497
Impacts:
Module developers