Created
November 26, 2019 23:33
-
-
Save Mykola-Veryha/45ea0dee9638f2ace1c190b837f664cf to your computer and use it in GitHub Desktop.
How taxonomy index work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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