-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHideStartsWithAProcessor.php
More file actions
42 lines (36 loc) · 1.05 KB
/
HideStartsWithAProcessor.php
File metadata and controls
42 lines (36 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* @file
* Contains \Drupal\facet_api_start_with_a_filter\Plugin\facetapi\HideStartWithA.
*/
namespace Drupal\facet_api_start_with_a_filter\Plugin\facetapi\processor;
use Drupal\facetapi\FacetInterface;
use Drupal\facetapi\Processor\BuildProcessorInterface;
use Drupal\facetapi\Processor\ProcessorPluginBase;
use Drupal\facetapi\Result\Result;
/**
* Provides a processor that hides results start with the letter A.
*
* @FacetApiProcessor(
* id = "hide_start_with_a",
* label = @Translation("Hide start with a"),
* description = @Translation("Hide all results that start with an 'A'"),
* stages = {
* "build" = 40
* }
* )
*/
class HideStartsWithAProcessor extends ProcessorPluginBase implements BuildProcessorInterface {
/**
* {@inheritdoc}
*/
public function build(FacetInterface $facet, array $results) {
/** @var Result $result */
foreach ($results as $id => $result) {
if (strpos(strtolower($result->getDisplayValue()), 'a') === 0) {
unset($results[$id]);
}
}
return $results;
}
}