ConfigurableSearchPluginBase.php

Same filename in other branches
  1. 9 core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php
  2. 10 core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php
  3. 11.x core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php

Namespace

Drupal\search\Plugin

File

core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php

View source
<?php

namespace Drupal\search\Plugin;

use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;

/**
 * Provides a base implementation for a configurable Search plugin.
 */
abstract class ConfigurableSearchPluginBase extends SearchPluginBase implements ConfigurableSearchPluginInterface {
    
    /**
     * The unique ID for the search page using this plugin.
     *
     * @var string
     */
    protected $searchPageId;
    
    /**
     * {@inheritdoc}
     */
    public function __construct(array $configuration, $plugin_id, $plugin_definition) {
        parent::__construct($configuration, $plugin_id, $plugin_definition);
        $this->setConfiguration($configuration);
    }
    
    /**
     * {@inheritdoc}
     */
    public function defaultConfiguration() {
        return [];
    }
    
    /**
     * {@inheritdoc}
     */
    public function getConfiguration() {
        return $this->configuration;
    }
    
    /**
     * {@inheritdoc}
     */
    public function setConfiguration(array $configuration) {
        $this->configuration = NestedArray::mergeDeep($this->defaultConfiguration(), $configuration);
    }
    
    /**
     * {@inheritdoc}
     */
    public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function calculateDependencies() {
        return [];
    }
    
    /**
     * {@inheritdoc}
     */
    public function setSearchPageId($search_page_id) {
        $this->searchPageId = $search_page_id;
        return $this;
    }

}

Classes

Title Deprecated Summary
ConfigurableSearchPluginBase Provides a base implementation for a configurable Search plugin.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.