abstract class SitemapBase in Sitemap 2.0.x
Same name and namespace in other branches
- 8.2 src/SitemapBase.php \Drupal\sitemap\SitemapBase
Base class for Sitemap plugin implementations.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\sitemap\SitemapBase implements SitemapInterface uses StringTranslationTrait
Expanded class hierarchy of SitemapBase
4 files declare their use of SitemapBase
- Book.php in src/
Plugin/ Sitemap/ Book.php - Frontpage.php in src/
Plugin/ Sitemap/ Frontpage.php - Menu.php in src/
Plugin/ Sitemap/ Menu.php - Vocabulary.php in src/
Plugin/ Sitemap/ Vocabulary.php
File
- src/
SitemapBase.php, line 14
Namespace
Drupal\sitemapView source
abstract class SitemapBase extends PluginBase implements SitemapInterface {
use StringTranslationTrait;
/**
* An associative array containing the configured settings of the sitemap_map.
*
* @var array
*/
public $settings = [];
/**
* A Boolean indicating whether this mapping is enabled.
*
* @var bool
*/
public $enabled = FALSE;
/**
* The weight of this mapping compared to others in the sitemap.
*
* @var int
*/
public $weight = 0;
/**
* The name of the provider that owns this mapping.
*
* @var string
*/
public $provider;
/**
* The global sitemap config.
*
* @var object
*/
protected $sitemapConfig;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->provider = $this->pluginDefinition['provider'];
if (empty($configuration)) {
$configuration = $this
->defaultConfiguration();
}
$this
->setConfiguration($configuration);
$this->sitemapConfig = \Drupal::config('sitemap.settings');
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
return [
'module' => 'sitemap',
];
}
/**
* {@inheritdoc}
*/
public function getLabel() {
return $this->pluginDefinition['title'];
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->pluginDefinition['description'];
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
// Provide a section title field for every mapping plugin.
$form['title'] = [
'#type' => 'textfield',
'#title' => $this
->t('Title'),
'#default_value' => $this->settings['title'],
'#description' => $this
->t('If you do not wish to display a title, leave this field blank.'),
'#weight' => -10,
];
return $form;
}
/**
* {@inheritdoc}
*/
public function settingsSummary() {
return [];
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
return [
'id' => $this
->getPluginId(),
'provider' => $this->pluginDefinition['provider'],
'status' => $this->enabled,
'weight' => $this->weight,
'settings' => $this->settings,
];
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
if (isset($configuration['enabled'])) {
$this->enabled = (bool) $configuration['enabled'];
}
if (isset($configuration['weight'])) {
$this->weight = (int) $configuration['weight'];
}
if (isset($configuration['settings'])) {
$this->settings = (array) $configuration['settings'];
}
return $this;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'provider' => $this->pluginDefinition['provider'],
'enabled' => $this->pluginDefinition['enabled'],
'weight' => isset($this->pluginDefinition['weight']) ? $this->pluginDefinition['weight'] : '',
'settings' => isset($this->pluginDefinition['settings']) ? $this->pluginDefinition['settings'] : [],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
SitemapBase:: |
public | property | A Boolean indicating whether this mapping is enabled. | |
SitemapBase:: |
public | property | The name of the provider that owns this mapping. | |
SitemapBase:: |
public | property | An associative array containing the configured settings of the sitemap_map. | |
SitemapBase:: |
protected | property | The global sitemap config. | |
SitemapBase:: |
public | property | The weight of this mapping compared to others in the sitemap. | |
SitemapBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
SitemapBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
|
SitemapBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
SitemapBase:: |
public | function |
Returns the administrative description for this mapping plugin. Overrides SitemapInterface:: |
|
SitemapBase:: |
public | function |
Returns the administrative label for this mapping plugin. Overrides SitemapInterface:: |
|
SitemapBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
SitemapBase:: |
public | function |
Returns a form to configure settings for the mapping. Overrides SitemapInterface:: |
4 |
SitemapBase:: |
public | function |
Returns a short summary for the current mapping settings. Overrides SitemapInterface:: |
|
SitemapBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
SitemapInterface:: |
public | function | Builds a renderable array for a sitemap item. | 4 |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |