diff --git a/core/modules/path/path.module b/core/modules/path/path.module index 563bfc7..85833d7 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -262,7 +262,7 @@ function path_form_taxonomy_form_term_alter(&$form, $form_state) { /** * Implements hook_taxonomy_term_insert(). */ -function path_taxonomy_term_insert($term) { +function path_taxonomy_term_insert(TaxonomyTerm $term) { if (isset($term->path)) { $path = $term->path; $path['alias'] = trim($path['alias']); @@ -279,7 +279,7 @@ function path_taxonomy_term_insert($term) { /** * Implements hook_taxonomy_term_update(). */ -function path_taxonomy_term_update($term) { +function path_taxonomy_term_update(TaxonomyTerm $term) { if (isset($term->path)) { $path = $term->path; $path['alias'] = trim($path['alias']); @@ -300,7 +300,7 @@ function path_taxonomy_term_update($term) { /** * Implements hook_taxonomy_term_delete(). */ -function path_taxonomy_term_delete($term) { +function path_taxonomy_term_delete(TaxonomyTerm $term) { // Delete all aliases associated with this term. path_delete(array('source' => 'taxonomy/term/' . $term->tid)); } diff --git a/core/modules/simpletest/tests/taxonomy_test.module b/core/modules/simpletest/tests/taxonomy_test.module index aae13a2..72fb29d 100644 --- a/core/modules/simpletest/tests/taxonomy_test.module +++ b/core/modules/simpletest/tests/taxonomy_test.module @@ -8,7 +8,7 @@ /** * Implements hook_taxonomy_term_load(). */ -function taxonomy_test_taxonomy_term_load($terms) { +function taxonomy_test_taxonomy_term_load(array $terms) { foreach ($terms as $term) { $antonym = taxonomy_test_get_antonym($term->tid); if ($antonym) { @@ -20,7 +20,7 @@ function taxonomy_test_taxonomy_term_load($terms) { /** * Implements hook_taxonomy_term_insert(). */ -function taxonomy_test_taxonomy_term_insert($term) { +function taxonomy_test_taxonomy_term_insert(TaxonomyTerm $term) { if (!empty($term->antonym)) { db_insert('taxonomy_term_antonym') ->fields(array( @@ -34,7 +34,7 @@ function taxonomy_test_taxonomy_term_insert($term) { /** * Implements hook_taxonomy_term_update(). */ -function taxonomy_test_taxonomy_term_update($term) { +function taxonomy_test_taxonomy_term_update(TaxonomyTerm $term) { if (!empty($term->antonym)) { db_merge('taxonomy_term_antonym') ->key(array('tid' => $term->tid)) @@ -48,7 +48,7 @@ function taxonomy_test_taxonomy_term_update($term) { /** * Implements hook_taxonomy_term_delete(). */ -function taxonomy_test_taxonomy_term_delete($term) { +function taxonomy_test_taxonomy_term_delete(TaxonomyTerm $term) { db_delete('taxonomy_term_antonym') ->condition('tid', $term->tid) ->execute(); diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc index b268b40..51d1bfa 100644 --- a/core/modules/taxonomy/taxonomy.admin.inc +++ b/core/modules/taxonomy/taxonomy.admin.inc @@ -102,14 +102,14 @@ function theme_taxonomy_overview_vocabularies($variables) { * Form builder for the vocabulary editing form. * * @param TaxonomyVocabulary|null $vocabulary - * (optional) The TaxonomyVocabulary entity to edit. If NULL or omitted, the + * (optional) The taxonomy vocabulary entity to edit. If NULL or omitted, the * form creates a new vocabulary. * * @ingroup forms * @see taxonomy_form_vocabulary_submit() * @see taxonomy_form_vocabulary_validate() */ -function taxonomy_form_vocabulary($form, &$form_state, $vocabulary = NULL) { +function taxonomy_form_vocabulary($form, &$form_state, TaxonomyVocabulary $vocabulary = NULL) { // During initial form build, add the entity to the form state for use // during form building and processing. During a rebuild, use what is in the // form state. @@ -237,11 +237,14 @@ function taxonomy_form_vocabulary_submit($form, &$form_state) { * Display a tree of all the terms in a vocabulary, with options to edit * each one. The form is made drag and drop by the theme function. * + * @param TaxonomyVocabulary $vocabulary + * The taxonomy vocabulary entity to list terms for. + * * @ingroup forms * @see taxonomy_overview_terms_submit() * @see theme_taxonomy_overview_terms() */ -function taxonomy_overview_terms($form, &$form_state, $vocabulary) { +function taxonomy_overview_terms($form, &$form_state, TaxonomyVocabulary $vocabulary) { global $pager_page_array, $pager_total, $pager_total_items; // Check for confirmation forms. @@ -628,16 +631,16 @@ function theme_taxonomy_overview_terms($variables) { * Form function for the term edit form. * * @param TaxonomyTerm|null $term - * (optional) The TaxonomyTerm entity to edit. If NULL or omitted, the - * form creates a new term. + * (optional) The taxonomy term entity to edit. If NULL or omitted, the form + * creates a new term. * @param TaxonomyVocabulary|null $vocabulary - * (optional) A TaxonomyVocabulary entity to create the term in. + * (optional) A taxonomy vocabulary entity to create the term in. * * @ingroup forms * @see taxonomy_form_term_validate() * @see taxonomy_form_term_submit() */ -function taxonomy_form_term($form, &$form_state, $term = NULL, $vocabulary = NULL) { +function taxonomy_form_term($form, &$form_state, TaxonomyTerm $term = NULL, TaxonomyVocabulary $vocabulary = NULL) { // During initial form build, add the term entity to the form state for use // during form building and processing. During a rebuild, use what is in the // form state. diff --git a/core/modules/taxonomy/taxonomy.api.php b/core/modules/taxonomy/taxonomy.api.php index 426306d..84fdfc7 100644 --- a/core/modules/taxonomy/taxonomy.api.php +++ b/core/modules/taxonomy/taxonomy.api.php @@ -16,10 +16,10 @@ * Modules implementing this hook can act on the vocabulary objects before they * are returned by taxonomy_vocabulary_load_multiple(). * - * @param $vocabulary - * An array of taxonomy vocabulary objects. + * @param array $vocabularies + * An array of taxonomy vocabulary entities. */ -function hook_taxonomy_vocabulary_load($vocabularies) { +function hook_taxonomy_vocabulary_load(array $vocabularies) { foreach ($vocabularies as $vocabulary) { $vocabulary->synonyms = variable_get('taxonomy_' . $vocabulary->vid . '_synonyms', FALSE); } @@ -32,10 +32,10 @@ function hook_taxonomy_vocabulary_load($vocabularies) { * Modules implementing this hook can act on the vocabulary object before it is * inserted or updated. * - * @param $vocabulary - * A taxonomy vocabulary object. + * @param TaxonomyVocabulary $vocabulary + * A taxonomy vocabulary entity. */ -function hook_taxonomy_vocabulary_presave($vocabulary) { +function hook_taxonomy_vocabulary_presave(TaxonomyVocabulary $vocabulary) { $vocabulary->foo = 'bar'; } @@ -45,10 +45,10 @@ function hook_taxonomy_vocabulary_presave($vocabulary) { * Modules implementing this hook can act on the vocabulary object when saved * to the database. * - * @param $vocabulary - * A taxonomy vocabulary object. + * @param TaxonomyVocabulary $vocabulary + * A taxonomy vocabulary entity. */ -function hook_taxonomy_vocabulary_insert($vocabulary) { +function hook_taxonomy_vocabulary_insert(TaxonomyVocabulary $vocabulary) { if ($vocabulary->synonyms) { variable_set('taxonomy_' . $vocabulary->vid . '_synonyms', TRUE); } @@ -59,10 +59,10 @@ function hook_taxonomy_vocabulary_insert($vocabulary) { * * Modules implementing this hook can act on the vocabulary object when updated. * - * @param $vocabulary - * A taxonomy vocabulary object. + * @param TaxonomyVocabulary $vocabulary + * A taxonomy vocabulary entity. */ -function hook_taxonomy_vocabulary_update($vocabulary) { +function hook_taxonomy_vocabulary_update(TaxonomyVocabulary $vocabulary) { $status = $vocabulary->synonyms ? TRUE : FALSE; if ($vocabulary->synonyms) { variable_set('taxonomy_' . $vocabulary->vid . '_synonyms', $status); @@ -76,14 +76,13 @@ function hook_taxonomy_vocabulary_update($vocabulary) { * field_attach_delete_bundle() is called and before the vocabulary is actually * removed from the database. * - * @param $vocabulary - * The taxonomy vocabulary object for the vocabulary that is about to be - * deleted. + * @param TaxonomyVocabulary $vocabulary + * The taxonomy vocabulary entity that is about to be deleted. * * @see hook_taxonomy_vocabulary_delete() * @see taxonomy_vocabulary_delete() */ -function hook_taxonomy_vocabulary_predelete($vocabulary) { +function hook_taxonomy_vocabulary_predelete(TaxonomyVocabulary $vocabulary) { if (variable_get('taxonomy_' . $vocabulary->vid . '_synonyms', FALSE)) { variable_del('taxonomy_' . $vocabulary->vid . '_synonyms'); } @@ -96,13 +95,13 @@ function hook_taxonomy_vocabulary_predelete($vocabulary) { * field_attach_delete_bundle() has been called and after the vocabulary has * been removed from the database. * - * @param $vocabulary - * The taxonomy vocabulary object for the vocabulary that has been deleted. + * @param TaxonomyVocabulary $vocabulary + * The taxonomy vocabulary entity that has been deleted. * * @see hook_taxonomy_vocabulary_predelete() * @see taxonomy_vocabulary_delete() */ -function hook_taxonomy_vocabulary_delete($vocabulary) { +function hook_taxonomy_vocabulary_delete(TaxonomyVocabulary $vocabulary) { if (variable_get('taxonomy_' . $vocabulary->vid . '_synonyms', FALSE)) { variable_del('taxonomy_' . $vocabulary->vid . '_synonyms'); } @@ -121,10 +120,10 @@ function hook_taxonomy_vocabulary_delete($vocabulary) { * altering properties provided by the {taxonomy_term_data} table, since this * may affect the way results are loaded from cache in subsequent calls. * - * @param $terms - * An array of term objects, indexed by tid. + * @param array $terms + * An array of taxonomy term entities, indexed by tid. */ -function hook_taxonomy_term_load($terms) { +function hook_taxonomy_term_load(array $terms) { $result = db_query('SELECT tid, foo FROM {mytable} WHERE tid IN (:tids)', array(':tids' => array_keys($terms))); foreach ($result as $record) { $terms[$record->tid]->foo = $record->foo; @@ -137,10 +136,10 @@ function hook_taxonomy_term_load($terms) { * Modules implementing this hook can act on the term object before it is * inserted or updated. * - * @param $term - * A term object. + * @param TaxonomyTerm $term + * A taxonomy term entity. */ -function hook_taxonomy_term_presave($term) { +function hook_taxonomy_term_presave(TaxonomyTerm $term) { $term->foo = 'bar'; } @@ -150,10 +149,10 @@ function hook_taxonomy_term_presave($term) { * Modules implementing this hook can act on the term object when saved to * the database. * - * @param $term - * A taxonomy term object. + * @param TaxonomyTerm $term + * A taxonomy term entity. */ -function hook_taxonomy_term_insert($term) { +function hook_taxonomy_term_insert(TaxonomyTerm $term) { if (!empty($term->synonyms)) { foreach (explode ("\n", str_replace("\r", '', $term->synonyms)) as $synonym) { if ($synonym) { @@ -173,10 +172,10 @@ function hook_taxonomy_term_insert($term) { * * Modules implementing this hook can act on the term object when updated. * - * @param $term - * A taxonomy term object. + * @param TaxonomyTerm $term + * A taxonomy term entity. */ -function hook_taxonomy_term_update($term) { +function hook_taxonomy_term_update(TaxonomyTerm $term) { hook_taxonomy_term_delete($term); if (!empty($term->synonyms)) { foreach (explode ("\n", str_replace("\r", '', $term->synonyms)) as $synonym) { @@ -199,12 +198,12 @@ function hook_taxonomy_term_update($term) { * field_attach_delete() is called and before the term is actually removed from * the database. * - * @param $term - * The taxonomy term object for the term that is about to be deleted. + * @param TaxonomyTerm $term + * The taxonomy term entity that is about to be deleted. * * @see taxonomy_term_delete() */ -function hook_taxonomy_term_predelete($term) { +function hook_taxonomy_term_predelete(TaxonomyTerm $term) { db_delete('term_synoynm')->condition('tid', $term->tid)->execute(); } @@ -214,12 +213,12 @@ function hook_taxonomy_term_predelete($term) { * This hook is invoked from taxonomy_term_delete() after field_attach_delete() * has been called and after the term has been removed from the database. * - * @param $term - * The taxonomy term object for the term that has been deleted. + * @param TaxonomyTerm $term + * The taxonomy term entity that has been deleted. * * @see taxonomy_term_delete() */ -function hook_taxonomy_term_delete($term) { +function hook_taxonomy_term_delete(TaxonomyTerm $term) { db_delete('term_synoynm')->condition('tid', $term->tid)->execute(); } @@ -237,7 +236,7 @@ function hook_taxonomy_term_delete($term) { * documentation respectively for details. * * @param $build - * A renderable array representing the node content. + * A renderable array representing the taxonomy term content. * * @see hook_entity_view_alter() */ @@ -248,7 +247,7 @@ function hook_taxonomy_term_view_alter(&$build) { } // Add a #post_render callback to act on the rendered HTML of the term. - $build['#post_render'][] = 'my_module_node_post_render'; + $build['#post_render'][] = 'my_module_taxonomy_term_post_render'; } /** diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index bc71c38..8b77f2a 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -394,7 +394,7 @@ function taxonomy_term_edit_access($term) { /** * Return the vocabulary name given the vocabulary object. */ -function taxonomy_admin_vocabulary_title_callback($vocabulary) { +function taxonomy_admin_vocabulary_title_callback(TaxonomyVocabulary $vocabulary) { return check_plain($vocabulary->name); } @@ -402,9 +402,9 @@ function taxonomy_admin_vocabulary_title_callback($vocabulary) { * Saves a vocabulary. * * @param TaxonomyVocabulary $vocabulary - * The TaxonomyVocabulary instance to be saved. + * The taxonomy vocabulary entity to be saved. */ -function taxonomy_vocabulary_save($vocabulary) { +function taxonomy_vocabulary_save(TaxonomyVocabulary $vocabulary) { return $vocabulary->save(); } @@ -432,7 +432,7 @@ function taxonomy_vocabulary_delete_multiple(array $vids) { /** * Implements hook_taxonomy_vocabulary_update(). */ -function taxonomy_taxonomy_vocabulary_update($vocabulary) { +function taxonomy_taxonomy_vocabulary_update(TaxonomyVocabulary $vocabulary) { // Reflect machine name changes in the definitions of existing 'taxonomy' // fields. if (!empty($vocabulary->original->machine_name) && $vocabulary->original->machine_name != $vocabulary->machine_name) { @@ -466,14 +466,14 @@ function taxonomy_taxonomy_vocabulary_update($vocabulary) { * TAXONOMY_HIERARCHY_MULTIPLE. * * @param TaxonomyVocabulary $vocabulary - * A vocabulary object. + * A taxonomy vocabulary entity. * @param $changed_term * An array of the term structure that was updated. * * @return * An integer that represents the level of the vocabulary's hierarchy. */ -function taxonomy_check_vocabulary_hierarchy($vocabulary, $changed_term) { +function taxonomy_check_vocabulary_hierarchy(TaxonomyVocabulary $vocabulary, $changed_term) { $tree = taxonomy_get_tree($vocabulary->vid); $hierarchy = TAXONOMY_HIERARCHY_DISABLED; foreach ($tree as $term) { @@ -503,14 +503,14 @@ function taxonomy_check_vocabulary_hierarchy($vocabulary, $changed_term) { * Saves a term object to the database. * * @param TaxonomyTerm $term - * The TaxonomyTerm object to be saved. + * The taxonomy term entity to be saved. * * @return * Status constant indicating whether term was inserted (SAVED_NEW) or updated * (SAVED_UPDATED). When inserting a new term, $term->tid will contain the * term ID of the newly created term. */ -function taxonomy_term_save($term) { +function taxonomy_term_save(TaxonomyTerm $term) { return $term->save(); } @@ -537,8 +537,8 @@ function taxonomy_term_delete_multiple(array $tids) { /** * Generate an array for rendering the given term. * - * @param $term - * A term object. + * @param TaxonomyTerm $term + * A taxonomy term entity. * @param $view_mode * View mode, e.g. 'full', 'teaser'... * @param $langcode @@ -548,7 +548,7 @@ function taxonomy_term_delete_multiple(array $tids) { * @return * An array as expected by drupal_render(). */ -function taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL) { +function taxonomy_term_view(TaxonomyTerm $term, $view_mode = 'full', $langcode = NULL) { if (!isset($langcode)) { $langcode = $GLOBALS['language_content']->langcode; } @@ -623,10 +623,10 @@ function template_preprocess_taxonomy_term(&$variables) { /** * Returns whether the current page is the page of the passed-in term. * - * @param $term - * A term object. + * @param TaxonomyTerm $term + * A taxonomy term entity. */ -function taxonomy_term_is_page($term) { +function taxonomy_term_is_page(TaxonomyTerm $term) { $page_term = menu_get_object('taxonomy_term', 2); return (!empty($page_term) ? $page_term->tid == $term->tid : FALSE); } @@ -657,10 +657,10 @@ function taxonomy_vocabulary_static_reset(array $ids = NULL) { } /** - * Return an array of all vocabulary objects. + * Return an array of all taxonomy vocabulary entities. * * @return - * An array of all vocabulary objects, indexed by vid. + * An array of all taxonomy vocabulary entities, indexed by vid. */ function taxonomy_get_vocabularies() { return taxonomy_vocabulary_load_multiple(FALSE, array()); @@ -935,8 +935,8 @@ function taxonomy_get_term_by_name($name, $vocabulary = NULL) { * this function. * * @return - * An array of term objects, indexed by tid. When no results are found, an - * empty array is returned. + * An array of taxonomy term entities, indexed by tid. When no results are + * found, an empty array is returned. * * @todo Remove $conditions in Drupal 8. */ @@ -966,13 +966,13 @@ function taxonomy_vocabulary_load_multiple($vids = array(), $conditions = array( } /** - * Return the vocabulary object matching a vocabulary ID. + * Return the taxonomy vocabulary entity matching a vocabulary ID. * * @param $vid * The vocabulary's ID. * - * @return - * The vocabulary object with all of its metadata, if exists, FALSE otherwise. + * @return TaxonomyVocabulary|false + * The taxonomy vocabulary entity, if exists, FALSE otherwise. * Results are statically cached. * * @see taxonomy_vocabulary_machine_name_load() @@ -983,13 +983,13 @@ function taxonomy_vocabulary_load($vid) { } /** - * Return the vocabulary object matching a vocabulary machine name. + * Return the taxonomy vocabulary entity matching a vocabulary machine name. * * @param $name * The vocabulary's machine name. * - * @return - * The vocabulary object with all of its metadata, if exists, FALSE otherwise. + * @return TaxonomyVocabulary|false + * The taxonomy vocabulary entity, if exists, FALSE otherwise. * Results are statically cached. * * @see taxonomy_vocabulary_load() @@ -1000,13 +1000,13 @@ function taxonomy_vocabulary_machine_name_load($name) { } /** - * Return the term object matching a term ID. + * Return the taxonomy term entity matching a term ID. * * @param $tid * A term's ID * - * @return - * A term object. Results are statically cached. + * @return TaxonomyTerm|false + * A taxonomy term entity. Results are statically cached. */ function taxonomy_term_load($tid) { if (!is_numeric($tid)) { @@ -1019,7 +1019,7 @@ function taxonomy_term_load($tid) { /** * Helper function for array_map purposes. */ -function _taxonomy_get_tid_from_term($term) { +function _taxonomy_get_tid_from_term(TaxonomyTerm $term) { return $term->tid; } @@ -1317,13 +1317,13 @@ function taxonomy_field_formatter_prepare_view($entity_type, $entities, $field, /** * Title callback for term pages. * - * @param $term - * A term object. + * @param TaxonomyTerm $term + * A taxonomy term entity. * * @return * The term name to be used as the page title. */ -function taxonomy_term_title($term) { +function taxonomy_term_title(TaxonomyTerm $term) { return $term->name; } @@ -1616,7 +1616,7 @@ function taxonomy_delete_node_index($node) { /** * Implements hook_taxonomy_term_delete(). */ -function taxonomy_taxonomy_term_delete($term) { +function taxonomy_taxonomy_term_delete(TaxonomyTerm $term) { if (variable_get('taxonomy_maintain_index_table', TRUE)) { // Clean up the {taxonomy_index} table when terms are deleted. db_delete('taxonomy_index')->condition('tid', $term->tid)->execute(); diff --git a/core/modules/taxonomy/taxonomy.pages.inc b/core/modules/taxonomy/taxonomy.pages.inc index 2630413..6453108 100644 --- a/core/modules/taxonomy/taxonomy.pages.inc +++ b/core/modules/taxonomy/taxonomy.pages.inc @@ -8,12 +8,10 @@ /** * Menu callback; displays all nodes associated with a term. * - * @param $term - * The taxonomy term. - * @return - * The page content. + * @param TaxonomyTerm $term + * The taxonomy term entity. */ -function taxonomy_term_page($term) { +function taxonomy_term_page(TaxonomyTerm $term) { // Assign the term name as the page title. drupal_set_title($term->name); @@ -62,10 +60,10 @@ function taxonomy_term_page($term) { /** * Generate the content feed for a taxonomy term. * - * @param $term - * The taxonomy term. + * @param TaxonomyTerm $term + * The taxonomy term entity. */ -function taxonomy_term_feed($term) { +function taxonomy_term_feed(TaxonomyTerm $term) { $channel['link'] = url('taxonomy/term/' . $term->tid, array('absolute' => TRUE)); $channel['title'] = variable_get('site_name', 'Drupal') . ' - ' . $term->name; // Only display the description if we have a single term, to avoid clutter and confusion.