RptMapWidget.php in Search API Location 8
File
modules/facets_map_widget/src/Plugin/facets/widget/RptMapWidget.php
View source
<?php
namespace Drupal\facets_map_widget\Plugin\facets\widget;
use Drupal\facets\FacetInterface;
use Drupal\facets\Widget\WidgetPluginBase;
class RptMapWidget extends WidgetPluginBase {
public function build(FacetInterface $facet) {
$results = $facet
->getResults();
$build['map'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#attributes' => [
'class' => [
'facets-map',
],
'id' => $facet
->id(),
],
];
$build['#attached']['library'][] = 'facets_map_widget/facets_map';
$build['#attached']['drupalSettings']['facets']['map'] = [
'id' => $facet
->id(),
'url' => $results[0]
->getUrl()
->toString(),
'results' => json_encode($results[0]
->getRawValue()),
];
return $build;
}
public function isPropertyRequired($name, $type) {
if ($name === 'rpt' && $type === 'processors') {
return TRUE;
}
return FALSE;
}
public function getQueryType() {
return 'search_api_rpt';
}
}
Classes
Name |
Description |
RptMapWidget |
A widget class that provides a map interface to narrow down facet results. |