SearchQueryAlterHooks.php

Namespace

Drupal\search_query_alter\Hook

File

core/modules/search/tests/modules/search_query_alter/src/Hook/SearchQueryAlterHooks.php

View source
<?php

declare (strict_types=1);
namespace Drupal\search_query_alter\Hook;

use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\Core\Hook\Attribute\Hook;

/**
 * Hook implementations for search_query_alter.
 */
class SearchQueryAlterHooks {
    
    /**
     * Implements hook_query_TAG_alter().
     *
     * Tags search_$type with $type node_search.
     */
    public function querySearchNodeSearchAlter(AlterableInterface $query) : void {
        // For testing purposes, restrict the query to node type 'article' only.
        $query->condition('n.type', 'article');
    }

}

Classes

Title Deprecated Summary
SearchQueryAlterHooks Hook implementations for search_query_alter.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.