Issue #3579758: Provide API for access checks on non-content entities

Prior to this change, the AI Search backend only supported access checks for content entities by hardcoding the entity load and access checks for items prefixed with entity:.

This commit introduces a flexible API to support access checks across all types of Search API datasources (including custom, non-content entities).

Changes included:

  • Added hook_ai_search_item_access to ai_search.api.php to allow modules to explicitly allow or forbid access to specific search items.
  • Refactored SearchApiAiSearchBackend::checkEntityAccess() to checkItemAccess().
  • Updated access logic to evaluate combined access results in the following order:
    1. Custom module overrides via hook_ai_search_item_access.
    2. The Search API datasource's native getItemAccessResult() method.
    3. Legacy fallback for content entities (checking $entity->access('view')) to preserve backward compatibility.
  • Defaulted access to FALSE for non-entity datasources if they are not explicitly allowed by the hook or the datasource.

Closes #3579758

Merge request reports

Loading