materio_ai: vectorization queue on node save, hash check and retry (V5)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ShDspHaZGwHoRZCsPBJzsM
This commit is contained in:
2026-11-16 20:50:05 +01:00
co-authored by Claude Opus 5.5
parent 96a255fcbc
commit 7d60678232
4 changed files with 206 additions and 0 deletions
@@ -0,0 +1,42 @@
<?php
/**
* @file
* Hooks of materio_ai: keep the vectors in step with the nodes.
*/
declare(strict_types=1);
use Drupal\node\NodeInterface;
/**
* Implements hook_ENTITY_TYPE_insert() for node.
*/
function materio_ai_node_insert(NodeInterface $node): void {
\Drupal::service('materio_ai.vectorizer')->enqueue($node);
}
/**
* Implements hook_ENTITY_TYPE_update() for node.
*
* Also covers a new translation, an unpublished node and a workflow change.
*/
function materio_ai_node_update(NodeInterface $node): void {
\Drupal::service('materio_ai.vectorizer')->enqueue($node);
}
/**
* Implements hook_ENTITY_TYPE_translation_delete() for node.
*/
function materio_ai_node_translation_delete(NodeInterface $translation): void {
\Drupal::service('materio_ai.embedding_storage')->delete((int) $translation->id(), $translation->language()->getId());
}
/**
* Implements hook_ENTITY_TYPE_delete() for node.
*
* Done at once, even when vectorization is switched off: no model needed.
*/
function materio_ai_node_delete(NodeInterface $node): void {
\Drupal::service('materio_ai.embedding_storage')->delete((int) $node->id());
}