Skip to content
Snippets Groups Projects
Commit cb9ec268 authored by Samit Khulve's avatar Samit Khulve Committed by Daniel Cothran
Browse files

Issue #3335589 by samit.310@gmail.com, sidharth_soman: Drupal Coding Standards Issues | phpcs

parent cb5da8d8
No related branches found
No related tags found
No related merge requests found
# Domain Access Search API
This module helps you filter your Search API index-based view so that only results for the
current display are shown. It's based on the Views filter that exists in the Domain Access
module, but that filter will not work for Search API-based views.
## Important note
This filter can be added to a Search API index-based view, but it will only work if you have
added the Domain Access field (field_domain_access, type: string) to your Search API index.
# Domain Access Search API
This module helps you filter your Search API index-based view so
that only results for the current display are shown. It's based
on the Views filter that exists in the Domain Access module,
but that filter will not work for Search API-based views.
## Important note
This filter can be added to a Search API index-based view,
but it will only work if you have added the Domain Access
field (field_domain_access, type: string) to your Search
API index.
......@@ -6,4 +6,3 @@ core_version_requirement: ^8 || ^9 || ^10
dependencies:
- search_api:search_api
- domain:domain
<?php
/**
* @file
* The Domain Access Search API module file.
*/
use Drupal\search_api\Entity\Index;
/**
......@@ -18,11 +23,12 @@ function domain_access_search_api_views_data_alter(array &$data) {
'filter' => [
'field' => 'field_domain_access',
'id' => 'domain_access_search_api_current_all_filter',
'title' => t('Search API (' . $index->id() . '): Available on current domain'),
'title' => t('Search API (@index_id): Available on current domain', ['@index_id' => $index->id()]),
'help' => t('Filters out nodes available on current domain (published to current domain or all affiliates).'),
],
];
// Since domains are not stored in the database, relationships cannot be used.
// Since domains are not stored in the database, relationships cannot
// be used.
unset($data[$table][DOMAIN_ACCESS_FIELD]['relationship']);
}
catch (\Exception $e) {
......
......@@ -2,7 +2,6 @@
namespace Drupal\domain_access_search_api\Plugin\views\filter;
use Drupal\domain\DomainNegotiatorInterface;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\filter\BooleanOperator;
use Drupal\views\ViewExecutable;
......@@ -21,7 +20,7 @@ class DomainAccessSearchApiCurrentAllFilter extends BooleanOperator {
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$this->value_value = t('Available on current domain');
$this->value_value = $this->t('Available on current domain');
}
/**
......@@ -44,7 +43,7 @@ class DomainAccessSearchApiCurrentAllFilter extends BooleanOperator {
public function query() {
$this->ensureMyTable();
/** @var DomainNegotiatorInterface $domain_negotiator */
/** @var \Drupal\domain\DomainNegotiatorInterface $domain_negotiator */
$domain_negotiator = \Drupal::service('domain.negotiator');
$current_domain = $domain_negotiator->getActiveDomain();
if ($current_domain && !empty($this->value)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment