Commit 545af033 authored by Hoi Sing Edison Wong's avatar Hoi Sing Edison Wong Committed by Markus Kalkbrenner
Browse files

Issue #3073444 by hswong3i, swentel, Siegrist, attisan, DamienMcKenna,...

Issue #3073444 by hswong3i, swentel, Siegrist, attisan, DamienMcKenna, Farnoosh, HitchShock, mirom, oxyc, Grimreaper, vasi1186, 3li, ayalon, dan2k3k4, bgilhome, StryKaizer, borisson_, geek-merlin, mkalkbrenner, gsquirrel, danharper, Murz, joshmiller, seanB, andypost, vaccinemedia, jmee, ransomweaver, chr.fritsch, kgeeraerts, sahaj, liquidcms, svendecabooter, oheller, sonfd, Leksat, uniquename, anruether, vuil, mhavelant: Create views plugins to render facets and summaries in filters and areas
parent dbd2285c
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -175,17 +175,8 @@ function facets_update_8005() {
 * Update facet blocks configuration with a block id used for AJAX support.
 */
function facets_update_8006() {
  $query = \Drupal::entityQuery('block')
    ->condition('plugin', 'facet_block', 'STARTS_WITH')
    ->execute();

  foreach ($query as $block_id) {
    $block = Block::load($block_id);
    $configuration = $block->get('settings');
    $configuration['block_id'] = $block_id;
    $block->set('settings', $configuration);
    $block->save();
  }
  // Empty update hook, we do not support this anymore.
  // @see https://www.drupal.org/project/facets/issues/3073444
}

/**
+26 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ use Drupal\facets\Entity\Facet;
use Drupal\facets\Entity\FacetSource;
use Drupal\facets\FacetInterface;
use Drupal\facets\FacetSource\SearchApiFacetSourceInterface;
use Drupal\search_api\Entity\Index;
use Drupal\views\Entity\View;
use Drupal\Core\Entity\EntityInterface;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
@@ -68,6 +69,11 @@ function facets_theme($existing, $type, $theme, $path) {
        'context' => [],
      ],
    ],
    'facets_views_plugin' => [
      'variables' => [
        'content' => [],
      ],
    ],
  ];
}

@@ -377,3 +383,23 @@ function facets_theme_suggestions_facets_result_item(array $variables) {
  }
  return $suggestions;
}

/**
 * Implements hook_views_data_alter().
 */
function facets_views_data_alter(array &$data) {

  /** @var \Drupal\search_api\IndexInterface $index */
  foreach (Index::loadMultiple() as $index) {
    $data['search_api_index_' . $index->id()]['facets'] = [
      'title' => t('Facets'),
      'help' => t('Displays facets in a filter or area.'),
      'filter' => [
        'id' => 'facets_filter',
      ],
      'area' => [
        'id' => 'facets_area',
      ],
    ];
  }
}
+0 −7
Original line number Diff line number Diff line
@@ -48,10 +48,3 @@ entity.facets_facet_source.edit_form:
    _title: 'Edit facet source configuration'
  requirements:
    _entity_create_access: 'facets_facet'

facets.block.ajax:
  path: '/facets-block-ajax'
  defaults:
    _controller: '\Drupal\facets\Controller\FacetBlockAjaxController::ajaxFacetBlockView'
  requirements:
    _access: 'TRUE'
+5 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ services:
      - '@plugin.manager.facets.facet_source'
      - '@plugin.manager.facets.processor'
      - '@entity_type.manager'
      - '@current_route_match'
  facets.utility.date_handler:
    class: Drupal\facets\Utility\FacetsDateHandler
    arguments:
@@ -38,6 +39,10 @@ services:
    arguments: ['@plugin.manager.block']
    tags:
      - { name: event_subscriber }
  facets.route_alter:
    class: \Drupal\facets\EventSubscriber\RouteAlterSubscriber
    tags:
      - { name: event_subscriber }
  facets.search_api_subscriber:
    class: Drupal\facets\EventSubscriber\SearchApiSubscriber
    arguments: ['@facets.manager']
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
   *     .once('my-custom-widget-on-change')
   *     .on('change', function () {
   *       // In this example $(this).val() will provide needed URL.
   *       $(this).trigger('facets_filter', [ $(this).val() ]);
   *       $(this).trigger('facets_filter', [ $(this).val(), false ]);
   *     });
   *
   * The facets module will trigger "facets_filtering" before filter is
Loading