diff --git a/core/modules/taxonomy/taxonomy.api.php b/core/modules/taxonomy/taxonomy.api.php index d2f41f6..347c25a 100644 --- a/core/modules/taxonomy/taxonomy.api.php +++ b/core/modules/taxonomy/taxonomy.api.php @@ -22,8 +22,8 @@ * The vocabulary object. */ function hook_taxonomy_vocabulary_create(\Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) { - if (!isset($vocabulary->synonyms)) { - $vocabulary->synonyms = FALSE; + if (!isset($term->foo)) { + $term->foo = 'some_initial_value'; } } @@ -38,7 +38,7 @@ function hook_taxonomy_vocabulary_create(\Drupal\taxonomy\Plugin\Core\Entity\Voc */ function hook_taxonomy_vocabulary_load(array $vocabularies) { foreach ($vocabularies as $vocabulary) { - $vocabulary->synonyms = variable_get('taxonomy_' . $vocabulary->id() . '_synonyms', FALSE); + $vocabulary->set('weight', $vocabulary->get('weight') * 10); } } @@ -53,7 +53,7 @@ function hook_taxonomy_vocabulary_load(array $vocabularies) { * A taxonomy vocabulary entity. */ function hook_taxonomy_vocabulary_presave(Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) { - $vocabulary->foo = 'bar'; + $vocabulary->set('foo') = 'bar'; } /** @@ -66,9 +66,12 @@ function hook_taxonomy_vocabulary_presave(Drupal\taxonomy\Plugin\Core\Entity\Voc * A taxonomy vocabulary entity. */ function hook_taxonomy_vocabulary_insert(Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) { - if ($vocabulary->synonyms) { - variable_set('taxonomy_' . $vocabulary->id() . '_synonyms', TRUE); - } + global $user; + watchdog( + 'paper trail', + 'Taxonomy vocabulary %name created by %user.', + array("%name" => $vocabulary->get('name'), "%user" => $user->get('name')) + ); } /** @@ -80,10 +83,12 @@ function hook_taxonomy_vocabulary_insert(Drupal\taxonomy\Plugin\Core\Entity\Voca * A taxonomy vocabulary entity. */ function hook_taxonomy_vocabulary_update(Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) { - $status = $vocabulary->synonyms ? TRUE : FALSE; - if ($vocabulary->synonyms) { - variable_set('taxonomy_' . $vocabulary->id() . '_synonyms', $status); - } + global $user; + watchdog( + 'paper trail', + 'Taxonomy vocabulary %name updated by %user.', + array("%name" => $vocabulary->get('name'), "%user" => $user->get('name')) + ); } /** @@ -100,8 +105,9 @@ function hook_taxonomy_vocabulary_update(Drupal\taxonomy\Plugin\Core\Entity\Voca * @see taxonomy_vocabulary_delete() */ function hook_taxonomy_vocabulary_predelete(Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) { - if (variable_get('taxonomy_' . $vocabulary->id() . '_synonyms', FALSE)) { - variable_del('taxonomy_' . $vocabulary->id() . '_synonyms'); + $id = config('foo.config')->get("vocabulary"); + if($vocabulary->id() == $id) { + drupal_set_message(t("The %name vocabulary is used by the foo module. Until you set the vocabulary setting to a different vocabulary, the foo functionality will be disabled.", array("%name" => $vocabulary->get('name')))) } } @@ -119,9 +125,12 @@ function hook_taxonomy_vocabulary_predelete(Drupal\taxonomy\Plugin\Core\Entity\V * @see taxonomy_vocabulary_delete() */ function hook_taxonomy_vocabulary_delete(Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) { - if (variable_get('taxonomy_' . $vocabulary->id() . '_synonyms', FALSE)) { - variable_del('taxonomy_' . $vocabulary->id() . '_synonyms'); - } + global $user; + watchdog( + 'paper trail', + 'Taxonomy vocabulary %name deleted by %user.', + array("%name" => $vocabulary->get('name'), "%user" => $user->get('name')) + ); } /** @@ -185,17 +194,10 @@ function hook_taxonomy_term_presave(Drupal\taxonomy\Term $term) { * A taxonomy term entity. */ function hook_taxonomy_term_insert(Drupal\taxonomy\Term $term) { - if (!empty($term->synonyms)) { - foreach (explode ("\n", str_replace("\r", '', $term->synonyms)) as $synonym) { - if ($synonym) { - db_insert('taxonomy_term_synonym') - ->fields(array( - 'tid' => $term->tid, - 'name' => rtrim($synonym), - )) - ->execute(); - } - } + $transalators = config('foo')->get('transalators'); + + foreach ($transalators as $user) { + drupal_mail('foo', 'term_transalation_needed', $user->mail, user_preferred_langcode($user), array("term" => $term)); } } @@ -208,18 +210,10 @@ function hook_taxonomy_term_insert(Drupal\taxonomy\Term $term) { * A taxonomy term entity. */ function hook_taxonomy_term_update(Drupal\taxonomy\Term $term) { - hook_taxonomy_term_delete($term); - if (!empty($term->synonyms)) { - foreach (explode ("\n", str_replace("\r", '', $term->synonyms)) as $synonym) { - if ($synonym) { - db_insert('taxonomy_term_synonym') - ->fields(array( - 'tid' => $term->tid, - 'name' => rtrim($synonym), - )) - ->execute(); - } - } + $transalators = config('foo.config')->get('transalators'); + + foreach ($transalators as $user) { + drupal_mail('foo', 'term_transalation_needed', $user->mail, user_preferred_langcode($user), array("term" => $term)); } } @@ -236,7 +230,10 @@ function hook_taxonomy_term_update(Drupal\taxonomy\Term $term) { * @see taxonomy_term_delete() */ function hook_taxonomy_term_predelete(Drupal\taxonomy\Term $term) { - db_delete('term_synoynm')->condition('tid', $term->tid)->execute(); + $id = config('foo.config')->get("term"); + if($term->id() == $id) { + drupal_set_message(t("The %name term is used by the foo module. Until you set the vocabulary setting to a different vocabulary, the foo functionality will be disabled.", array("%name" => $vocabulary->get('name')))) + } } /**