class TermName
Same name in this branch
- 11.x core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php \Drupal\taxonomy\Plugin\views\argument_validator\TermName
Same name and namespace in other branches
- 9 core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php \Drupal\taxonomy\Plugin\views\argument_validator\TermName
- 9 core/modules/taxonomy/src/Plugin/views/field/TermName.php \Drupal\taxonomy\Plugin\views\field\TermName
- 8.9.x core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php \Drupal\taxonomy\Plugin\views\argument_validator\TermName
- 8.9.x core/modules/taxonomy/src/Plugin/views/field/TermName.php \Drupal\taxonomy\Plugin\views\field\TermName
- 10 core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php \Drupal\taxonomy\Plugin\views\argument_validator\TermName
- 10 core/modules/taxonomy/src/Plugin/views/field/TermName.php \Drupal\taxonomy\Plugin\views\field\TermName
Displays taxonomy term names and allows converting spaces to hyphens.
Attributes
#[ViewsField("term_name")]
Hierarchy
- class \Drupal\taxonomy\Plugin\views\field\TermName
Expanded class hierarchy of TermName
File
-
core/
modules/ taxonomy/ src/ Plugin/ views/ field/ TermName.php, line 15
Namespace
Drupal\taxonomy\Plugin\views\fieldView source
class TermName extends EntityField {
/**
* {@inheritdoc}
*/
public function getItems(ResultRow $values) {
$items = parent::getItems($values);
if ($this->options['convert_spaces']) {
foreach ($items as &$item) {
// Replace spaces with hyphens.
$name = str_replace(' ', '-', $item['raw']->get('value')
->getValue());
empty($this->options['settings']['link_to_entity']) ? $item['rendered']['#context']['value'] = $name : ($item['rendered']['#title']['#context']['value'] = $name);
}
}
return $items;
}
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['convert_spaces'] = [
'default' => FALSE,
];
return $options;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['convert_spaces'] = [
'#title' => $this->t('Convert spaces in term names to hyphens'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['convert_spaces']),
];
parent::buildOptionsForm($form, $form_state);
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|---|
DependencySerializationTrait::$_entityStorages | protected | property | An array of entity type IDs keyed by the property name of their storages. | |||
DependencySerializationTrait::$_serviceIds | protected | property | An array of service IDs keyed by property name used for serialization. | |||
DependencySerializationTrait::__sleep | public | function | 3 | |||
DependencySerializationTrait::__wakeup | public | function | 3 | |||
DependencyTrait::$dependencies | protected | property | The object's dependencies. | |||
DependencyTrait::addDependencies | protected | function | Adds multiple dependencies. | |||
DependencyTrait::addDependency | protected | function | Adds a dependency. | |||
MessengerTrait::$messenger | protected | property | The messenger. | 25 | ||
MessengerTrait::messenger | public | function | Gets the messenger. | 25 | ||
MessengerTrait::setMessenger | public | function | Sets the messenger. | |||
PluginBase::$configuration | protected | property | Configuration information passed into the plugin. | 1 | ||
PluginBase::$pluginDefinition | protected | property | The plugin implementation definition. | 1 | ||
PluginBase::$pluginId | protected | property | The plugin ID. | |||
PluginBase::DERIVATIVE_SEPARATOR | constant | A string which is used to separate base plugin IDs from the derivative ID. | ||||
PluginBase::getBaseId | public | function | Gets the base_plugin_id of the plugin instance. | Overrides DerivativeInspectionInterface::getBaseId | ||
PluginBase::getDerivativeId | public | function | Gets the derivative_id of the plugin instance. | Overrides DerivativeInspectionInterface::getDerivativeId | ||
PluginBase::getPluginDefinition | public | function | Gets the definition of the plugin implementation. | Overrides PluginInspectionInterface::getPluginDefinition | 2 | |
PluginBase::getPluginId | public | function | Gets the plugin ID of the plugin instance. | Overrides PluginInspectionInterface::getPluginId | ||
PluginBase::isConfigurable | Deprecated | public | function | Determines if the plugin is configurable. | ||
PluginDependencyTrait::calculatePluginDependencies | protected | function | Calculates and adds dependencies of a specific plugin instance. | 1 | ||
PluginDependencyTrait::getPluginDependencies | protected | function | Calculates and returns dependencies of a specific plugin instance. | |||
PluginDependencyTrait::moduleHandler | protected | function | Wraps the module handler. | 1 | ||
PluginDependencyTrait::themeHandler | protected | function | Wraps the theme handler. | 1 | ||
StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 | ||
StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | |||
StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | |||
StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | |||
StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 | ||
StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. | 1 | ||
TermName::buildOptionsForm | public | function | Default option form that provides label widget that all fields should have. | |||
TermName::defineOptions | protected | function | Information about options for all kinds of purposes will be held here. | |||
TermName::getItems | public | function | Gets an array of items for the field. | |||
TrustedCallbackInterface::THROW_EXCEPTION | constant | Untrusted callbacks throw exceptions. | ||||
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION | constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.