Mercurial > hg > isophonics-drupal-site
comparison core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\search\Plugin; | |
4 | |
5 use Drupal\Component\Utility\NestedArray; | |
6 use Drupal\Core\Form\FormStateInterface; | |
7 | |
8 /** | |
9 * Provides a base implementation for a configurable Search plugin. | |
10 */ | |
11 abstract class ConfigurableSearchPluginBase extends SearchPluginBase implements ConfigurableSearchPluginInterface { | |
12 | |
13 /** | |
14 * The unique ID for the search page using this plugin. | |
15 * | |
16 * @var string | |
17 */ | |
18 protected $searchPageId; | |
19 | |
20 /** | |
21 * {@inheritdoc} | |
22 */ | |
23 public function __construct(array $configuration, $plugin_id, $plugin_definition) { | |
24 parent::__construct($configuration, $plugin_id, $plugin_definition); | |
25 | |
26 $this->setConfiguration($configuration); | |
27 } | |
28 | |
29 /** | |
30 * {@inheritdoc} | |
31 */ | |
32 public function defaultConfiguration() { | |
33 return []; | |
34 } | |
35 | |
36 /** | |
37 * {@inheritdoc} | |
38 */ | |
39 public function getConfiguration() { | |
40 return $this->configuration; | |
41 } | |
42 | |
43 /** | |
44 * {@inheritdoc} | |
45 */ | |
46 public function setConfiguration(array $configuration) { | |
47 $this->configuration = NestedArray::mergeDeep($this->defaultConfiguration(), $configuration); | |
48 } | |
49 | |
50 /** | |
51 * {@inheritdoc} | |
52 */ | |
53 public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { | |
54 } | |
55 | |
56 /** | |
57 * {@inheritdoc} | |
58 */ | |
59 public function calculateDependencies() { | |
60 return []; | |
61 } | |
62 | |
63 /** | |
64 * {@inheritdoc} | |
65 */ | |
66 public function setSearchPageId($search_page_id) { | |
67 $this->searchPageId = $search_page_id; | |
68 return $this; | |
69 } | |
70 | |
71 } |