diff --git a/entity.module b/entity.module index da0acf6979..9a680b5b74 100644 --- a/entity.module +++ b/entity.module @@ -1490,79 +1490,87 @@ function entity_entity_info_alter(&$entity_info) { * Adds metadata and callbacks for core entities to the entity info. */ function _entity_info_add_metadata(&$entity_info) { + $entity_info_metadata = array(); + // Set plural labels. - $entity_info['node']['plural label'] = t('Nodes'); - $entity_info['user']['plural label'] = t('Users'); - $entity_info['file']['plural label'] = t('Files'); + $entity_info_metadata['node']['plural label'] = t('Nodes'); + $entity_info_metadata['user']['plural label'] = t('Users'); + $entity_info_metadata['file']['plural label'] = t('Files'); // Set descriptions. - $entity_info['node']['description'] = t('Nodes represent the main site content items.'); - $entity_info['user']['description'] = t('Users who have created accounts on your site.'); - $entity_info['file']['description'] = t('Uploaded file.'); + $entity_info_metadata['node']['description'] = t('Nodes represent the main site content items.'); + $entity_info_metadata['user']['description'] = t('Users who have created accounts on your site.'); + $entity_info_metadata['file']['description'] = t('Uploaded file.'); // Set access callbacks. - $entity_info['node']['access callback'] = 'entity_metadata_no_hook_node_access'; - $entity_info['user']['access callback'] = 'entity_metadata_user_access'; + $entity_info_metadata['node']['access callback'] = 'entity_metadata_no_hook_node_access'; + $entity_info_metadata['user']['access callback'] = 'entity_metadata_user_access'; // File entity has it's own entity_access function. if (!module_exists('file_entity')) { - $entity_info['file']['access callback'] = 'entity_metadata_file_access'; + $entity_info_metadata['file']['access callback'] = 'entity_metadata_file_access'; } // CRUD function callbacks. - $entity_info['node']['creation callback'] = 'entity_metadata_create_node'; - $entity_info['node']['save callback'] = 'node_save'; - $entity_info['node']['deletion callback'] = 'node_delete'; - $entity_info['node']['revision deletion callback'] = 'node_revision_delete'; - $entity_info['user']['creation callback'] = 'entity_metadata_create_object'; - $entity_info['user']['save callback'] = 'entity_metadata_user_save'; - $entity_info['user']['deletion callback'] = 'user_delete'; - $entity_info['file']['save callback'] = 'file_save'; - $entity_info['file']['deletion callback'] = 'entity_metadata_delete_file'; + $entity_info_metadata['node']['creation callback'] = 'entity_metadata_create_node'; + $entity_info_metadata['node']['save callback'] = 'node_save'; + $entity_info_metadata['node']['deletion callback'] = 'node_delete'; + $entity_info_metadata['node']['revision deletion callback'] = 'node_revision_delete'; + $entity_info_metadata['user']['creation callback'] = 'entity_metadata_create_object'; + $entity_info_metadata['user']['save callback'] = 'entity_metadata_user_save'; + $entity_info_metadata['user']['deletion callback'] = 'user_delete'; + $entity_info_metadata['file']['save callback'] = 'file_save'; + $entity_info_metadata['file']['deletion callback'] = 'entity_metadata_delete_file'; // Form callbacks. - $entity_info['node']['form callback'] = 'entity_metadata_form_node'; - $entity_info['user']['form callback'] = 'entity_metadata_form_user'; + $entity_info_metadata['node']['form callback'] = 'entity_metadata_form_node'; + $entity_info_metadata['user']['form callback'] = 'entity_metadata_form_user'; // URI callbacks. - if (!isset($entity_info['file']['uri callback'])) { - $entity_info['file']['uri callback'] = 'entity_metadata_uri_file'; + if (!isset($entity_info_metadata['file']['uri callback'])) { + $entity_info_metadata['file']['uri callback'] = 'entity_metadata_uri_file'; } // View callbacks. - $entity_info['node']['view callback'] = 'entity_metadata_view_node'; - $entity_info['user']['view callback'] = 'entity_metadata_view_single'; + $entity_info_metadata['node']['view callback'] = 'entity_metadata_view_node'; + $entity_info_metadata['user']['view callback'] = 'entity_metadata_view_single'; if (module_exists('comment')) { - $entity_info['comment']['plural label'] = t('Comments'); - $entity_info['comment']['description'] = t('Remark or note that refers to a node.'); - $entity_info['comment']['access callback'] = 'entity_metadata_comment_access'; - $entity_info['comment']['creation callback'] = 'entity_metadata_create_comment'; - $entity_info['comment']['save callback'] = 'comment_save'; - $entity_info['comment']['deletion callback'] = 'comment_delete'; - $entity_info['comment']['view callback'] = 'entity_metadata_view_comment'; - $entity_info['comment']['form callback'] = 'entity_metadata_form_comment'; + $entity_info_metadata['comment']['plural label'] = t('Comments'); + $entity_info_metadata['comment']['description'] = t('Remark or note that refers to a node.'); + $entity_info_metadata['comment']['access callback'] = 'entity_metadata_comment_access'; + $entity_info_metadata['comment']['creation callback'] = 'entity_metadata_create_comment'; + $entity_info_metadata['comment']['save callback'] = 'comment_save'; + $entity_info_metadata['comment']['deletion callback'] = 'comment_delete'; + $entity_info_metadata['comment']['view callback'] = 'entity_metadata_view_comment'; + $entity_info_metadata['comment']['form callback'] = 'entity_metadata_form_comment'; } if (module_exists('taxonomy')) { - $entity_info['taxonomy_term']['plural label'] = t('Taxonomy terms'); - $entity_info['taxonomy_term']['description'] = t('Taxonomy terms are used for classifying content.'); - $entity_info['taxonomy_term']['access callback'] = 'entity_metadata_taxonomy_access'; - $entity_info['taxonomy_term']['creation callback'] = 'entity_metadata_create_object'; - $entity_info['taxonomy_term']['save callback'] = 'taxonomy_term_save'; - $entity_info['taxonomy_term']['deletion callback'] = 'taxonomy_term_delete'; - $entity_info['taxonomy_term']['view callback'] = 'entity_metadata_view_single'; - $entity_info['taxonomy_term']['form callback'] = 'entity_metadata_form_taxonomy_term'; - - $entity_info['taxonomy_vocabulary']['plural label'] = t('Taxonomy vocabularies'); - $entity_info['taxonomy_vocabulary']['description'] = t('Vocabularies contain related taxonomy terms, which are used for classifying content.'); - $entity_info['taxonomy_vocabulary']['access callback'] = 'entity_metadata_taxonomy_access'; - $entity_info['taxonomy_vocabulary']['creation callback'] = 'entity_metadata_create_object'; - $entity_info['taxonomy_vocabulary']['save callback'] = 'taxonomy_vocabulary_save'; - $entity_info['taxonomy_vocabulary']['deletion callback'] = 'taxonomy_vocabulary_delete'; - $entity_info['taxonomy_vocabulary']['form callback'] = 'entity_metadata_form_taxonomy_vocabulary'; + $entity_info_metadata['taxonomy_term']['plural label'] = t('Taxonomy terms'); + $entity_info_metadata['taxonomy_term']['description'] = t('Taxonomy terms are used for classifying content.'); + $entity_info_metadata['taxonomy_term']['access callback'] = 'entity_metadata_taxonomy_access'; + $entity_info_metadata['taxonomy_term']['creation callback'] = 'entity_metadata_create_object'; + $entity_info_metadata['taxonomy_term']['save callback'] = 'taxonomy_term_save'; + $entity_info_metadata['taxonomy_term']['deletion callback'] = 'taxonomy_term_delete'; + $entity_info_metadata['taxonomy_term']['view callback'] = 'entity_metadata_view_single'; + $entity_info_metadata['taxonomy_term']['form callback'] = 'entity_metadata_form_taxonomy_term'; + + $entity_info_metadata['taxonomy_vocabulary']['plural label'] = t('Taxonomy vocabularies'); + $entity_info_metadata['taxonomy_vocabulary']['description'] = t('Vocabularies contain related taxonomy terms, which are used for classifying content.'); + $entity_info_metadata['taxonomy_vocabulary']['access callback'] = 'entity_metadata_taxonomy_access'; + $entity_info_metadata['taxonomy_vocabulary']['creation callback'] = 'entity_metadata_create_object'; + $entity_info_metadata['taxonomy_vocabulary']['save callback'] = 'taxonomy_vocabulary_save'; + $entity_info_metadata['taxonomy_vocabulary']['deletion callback'] = 'taxonomy_vocabulary_delete'; + $entity_info_metadata['taxonomy_vocabulary']['form callback'] = 'entity_metadata_form_taxonomy_vocabulary'; // Token type mapping. - $entity_info['taxonomy_term']['token type'] = 'term'; - $entity_info['taxonomy_vocabulary']['token type'] = 'vocabulary'; + $entity_info_metadata['taxonomy_term']['token type'] = 'term'; + $entity_info_metadata['taxonomy_vocabulary']['token type'] = 'vocabulary'; } + + // Allow modules to alter entity info metadata. + drupal_alter('entity_info_metadata', $entity_info_metadata); + + // Apply entity info metadata. + $entity_info = drupal_array_merge_deep($entity_info, $entity_info_metadata); } /**