summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-05-15 16:43:08 (GMT)
committerAlex Pott2015-05-15 16:43:08 (GMT)
commit5a54339636d972c809bc2b9a975bf9b91b76e7e1 (patch)
tree7797d2e968266feecf57d01e739d53ddae393fd7
parentbe4b247681c107e83f334e2cb32ecdef7f241513 (diff)
Issue #2478855 by xjm, JacobSanford, jhodgdon: Improve documentation for hook_entity_type_build() and hook_entity_type_alter()
-rw-r--r--core/modules/system/entity.api.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php
index 9d9b33e..8b8e370 100644
--- a/core/modules/system/entity.api.php
+++ b/core/modules/system/entity.api.php
@@ -619,12 +619,16 @@ function hook_ENTITY_TYPE_create_access(\Drupal\Core\Session\AccountInterface $a
* Modules may implement this hook to add information to defined entity types,
* as defined in \Drupal\Core\Entity\EntityTypeInterface.
*
+ * To alter existing information or to add information dynamically, use
+ * hook_entity_type_alter().
+ *
* @param \Drupal\Core\Entity\EntityTypeInterface[] $entity_types
* An associative array of all entity type definitions, keyed by the entity
* type name. Passed by reference.
*
* @see \Drupal\Core\Entity\Entity
* @see \Drupal\Core\Entity\EntityTypeInterface
+ * @see hook_entity_type_alter()
*/
function hook_entity_type_build(array &$entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
@@ -641,8 +645,12 @@ function hook_entity_type_build(array &$entity_types) {
* \Drupal\Core\Entity\Annotation\EntityType and all the ones additionally
* provided by modules can be altered here.
*
- * Do not use this hook to add information to entity types, unless you are just
- * filling-in default values. Use hook_entity_type_build() instead.
+ * Do not use this hook to add information to entity types, unless one of the
+ * following is true:
+ * - You are filling in default values.
+ * - You need to dynamically add information only in certain circumstances.
+ * - Your hook needs to run after hook_entity_type_build() implementations.
+ * Use hook_entity_type_build() instead in all other cases.
*
* @param \Drupal\Core\Entity\EntityTypeInterface[] $entity_types
* An associative array of all entity type definitions, keyed by the entity