class MappingTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/MappingTest.php \Drupal\views_test_data\Plugin\views\style\MappingTest
- 11.x core/tests/Drupal/KernelTests/Config/Schema/MappingTest.php \Drupal\KernelTests\Config\Schema\MappingTest
- 10 core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/MappingTest.php \Drupal\views_test_data\Plugin\views\style\MappingTest
- 10 core/tests/Drupal/KernelTests/Config/Schema/MappingTest.php \Drupal\KernelTests\Config\Schema\MappingTest
- 8.9.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/MappingTest.php \Drupal\views_test_data\Plugin\views\style\MappingTest
Provides a test plugin for the mapping style.
Plugin annotation
@ViewsStyle(
id = "mapping_test",
title = @Translation("Field mapping"),
help = @Translation("Maps specific fields to specific purposes."),
theme = "views_view_mapping_test",
display_types = {"normal", "test"}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\views\Plugin\views\style\StylePluginBase extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\style\Mapping extends \Drupal\views\Plugin\views\style\StylePluginBase
- class \Drupal\views_test_data\Plugin\views\style\MappingTest extends \Drupal\views\Plugin\views\style\Mapping
- class \Drupal\views\Plugin\views\style\Mapping extends \Drupal\views\Plugin\views\style\StylePluginBase
- class \Drupal\views\Plugin\views\style\StylePluginBase extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of MappingTest
Related topics
File
-
core/
modules/ views/ tests/ modules/ views_test_data/ src/ Plugin/ views/ style/ MappingTest.php, line 21
Namespace
Drupal\views_test_data\Plugin\views\styleView source
class MappingTest extends Mapping {
/**
* {@inheritdoc}
*/
protected function defineMapping() {
return [
'title_field' => [
'#title' => $this->t('Title field'),
'#description' => $this->t('Choose the field with the custom title.'),
'#toggle' => TRUE,
'#required' => TRUE,
],
'name_field' => [
'#title' => $this->t('Name field'),
'#description' => $this->t('Choose the field with the custom name.'),
],
'numeric_field' => [
'#title' => $this->t('Numeric field'),
'#description' => $this->t('Select one or more numeric fields.'),
'#multiple' => TRUE,
'#toggle' => TRUE,
'#filter' => 'filterNumericFields',
'#required' => TRUE,
],
];
}
/**
* Restricts the allowed fields to only numeric fields.
*
* @param array $fields
* An array of field labels, keyed by the field ID.
*/
protected function filterNumericFields(&$fields) {
foreach ($this->view->field as $id => $field) {
if (!$field instanceof NumericField) {
unset($fields[$id]);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.