function hook_taxonomy_term_create

Act on a newly created term.

This hook runs after a new term object has just been instantiated. It can be used to set initial values, e.g. to provide defaults.

Parameters

\Drupal\taxonomy\Plugin\Core\Entity\Term $term: The term object.

Related topics

1 function implements hook_taxonomy_term_create()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

entity_crud_hook_test_taxonomy_term_create in drupal/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_taxonomy_term_create().

File

drupal/core/modules/taxonomy/taxonomy.api.php, line 137
Hooks provided by the Taxonomy module.

Code

function hook_taxonomy_term_create(\Drupal\taxonomy\Plugin\Core\Entity\Term $term) {
  if (!isset($term->foo)) {
    $term->foo = 'some_initial_value';
  }
}