Skip to content

Instantly share code, notes, and snippets.

@Mykola-Veryha
Created November 26, 2019 23:33
Show Gist options
  • Save Mykola-Veryha/45ea0dee9638f2ace1c190b837f664cf to your computer and use it in GitHub Desktop.
Save Mykola-Veryha/45ea0dee9638f2ace1c190b837f664cf to your computer and use it in GitHub Desktop.
How taxonomy index work
<?php
/**
* Implements hook_ENTITY_TYPE_insert() for node entities.
*/
function taxonomy_node_insert(EntityInterface $node) {
// Add taxonomy index entries for the node.
taxonomy_build_node_index($node);
}
/**
* Implements hook_ENTITY_TYPE_update() for node entities.
*/
function taxonomy_node_update(EntityInterface $node) {
// If we're not dealing with the default revision of the node, do not make any
// change to the taxonomy index.
if (!$node->isDefaultRevision()) {
return;
}
taxonomy_delete_node_index($node);
taxonomy_build_node_index($node);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment