Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
API page: https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...
The 'entity keys' is optional, and should be marked as such.
Furthermore, some of its array items get filled by entity_get_info() with defaults:
foreach ($entity_info as $name => $data) {
$entity_info[$name] += array(
'fieldable' => FALSE,
'controller class' => 'DrupalDefaultEntityController',
'static cache' => TRUE,
'field cache' => TRUE,
'load hook' => $name . '_load',
'bundles' => array(),
'view modes' => array(),
'entity keys' => array(),
'translation' => array(),
);
$entity_info[$name]['entity keys'] += array(
'revision' => '',
'bundle' => '',
);
This should be documented too. (See https://api.drupal.org/api/drupal/includes!common.inc/function/entity_ge...)
Comment | File | Size | Author |
---|---|---|---|
#4 | document_which_of-2393569-4.patch | 2.03 KB | talhaparacha |
#1 | system-improve_hook_entity_info_doc-2393569-1.patch | 1.67 KB | vbouchet |
Comments
Comment #1
vbouchetPlease find a first patch, not sure it covers the entire issue.
Comment #2
joachim CreditAttribution: joachim commentedI think this might be a patch for another issue... :)
Comment #3
vbouchetYeah, by reading the issue now I understand the issue was only about 'entity keys'. I initially thought part of the issue was about 'entity keys' and another part was about some default value for other fields was not properly documented.
Comment #4
talhaparacha CreditAttribution: talhaparacha as a volunteer commentedPatch applies cleanly at commit # 731dfac.
Comment #5
joachim CreditAttribution: joachim commentedThanks for the patch. Looks good to me.
Comment #6
jhodgdonThanks! I don't think this patch addresses everything in the issue summary though. The summary says that we should document the defaults for all of the entity keys that have defaults, and this patch only addresses a few of them.
Comment #7
talhaparacha CreditAttribution: talhaparacha as a volunteer commentedYes but I think only 'revision' and 'bundle' elements from entity keys get default values in entity_get_info().
Comment #8
jhodgdonLooking at the issue summary, there are several keys in the entity info that get defaults (there are only two inside the 'entity keys' portion). Not all of the keys in the outer entity info have their defaults documented. Is that out of scope for this issue?
Comment #9
joachim CreditAttribution: joachim commentedIt's out of scope for the issue as I filed it, yes. But you're the docs maintainer, so if you want to widen the scope... :)
Comment #10
jhodgdonEither way. I'll go ahead and mark the current patch RTBC then. If someone wants to either file another (very minor) issue about putting in the defaults for the other keys, or make another patch here, feel free. I am kind of past caring a lot about 7.x docs at this point enough to push for that update.
Comment #11
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedCommitted to 7.x - thanks!