class AttachmentTestFormatter
Same name and namespace in other branches
- 11.x core/modules/views/tests/modules/views_test_formatter/src/Plugin/Field/FieldFormatter/AttachmentTestFormatter.php \Drupal\views_test_formatter\Plugin\Field\FieldFormatter\AttachmentTestFormatter
- 10 core/modules/views/tests/modules/views_test_formatter/src/Plugin/Field/FieldFormatter/AttachmentTestFormatter.php \Drupal\views_test_formatter\Plugin\Field\FieldFormatter\AttachmentTestFormatter
- 9 core/modules/views/tests/modules/views_test_formatter/src/Plugin/Field/FieldFormatter/AttachmentTestFormatter.php \Drupal\views_test_formatter\Plugin\Field\FieldFormatter\AttachmentTestFormatter
- 8.9.x core/modules/views/tests/modules/views_test_formatter/src/Plugin/Field/FieldFormatter/AttachmentTestFormatter.php \Drupal\views_test_formatter\Plugin\Field\FieldFormatter\AttachmentTestFormatter
Plugin implementation of the 'number_unformatted_with_attachment' formatter.
Attributes
#[FieldFormatter(id: 'number_unformatted_with_attachment', label: new TranslatableMarkup('Unformatted, with attachments'), field_types: [
'integer',
'decimal',
'float',
])]
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\DependencyInjection\AutowiredInstanceTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\Core\Field\PluginSettingsBase implements \Drupal\Core\Field\PluginSettingsInterface, \Drupal\Component\Plugin\DependentPluginInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Field\FormatterBase implements \Drupal\Core\Field\FormatterInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface extends \Drupal\Core\Field\PluginSettingsBase
- class \Drupal\Core\Field\Plugin\Field\FieldFormatter\NumericUnformattedFormatter extends \Drupal\Core\Field\FormatterBase
- class \Drupal\views_test_formatter\Plugin\Field\FieldFormatter\AttachmentTestFormatter extends \Drupal\Core\Field\Plugin\Field\FieldFormatter\NumericUnformattedFormatter
- class \Drupal\Core\Field\Plugin\Field\FieldFormatter\NumericUnformattedFormatter extends \Drupal\Core\Field\FormatterBase
- class \Drupal\Core\Field\FormatterBase implements \Drupal\Core\Field\FormatterInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface extends \Drupal\Core\Field\PluginSettingsBase
- class \Drupal\Core\Field\PluginSettingsBase implements \Drupal\Core\Field\PluginSettingsInterface, \Drupal\Component\Plugin\DependentPluginInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\DependencyInjection\AutowiredInstanceTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of AttachmentTestFormatter
File
-
core/
modules/ views/ tests/ modules/ views_test_formatter/ src/ Plugin/ Field/ FieldFormatter/ AttachmentTestFormatter.php, line 15
Namespace
Drupal\views_test_formatter\Plugin\Field\FieldFormatterView source
class AttachmentTestFormatter extends NumericUnformattedFormatter {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = parent::viewElements($items, $langcode);
// Add dummy attachments.
$entity_id = $items->getEntity()
->id();
$elements['#attached']['library'][] = 'foo/fake_library';
$elements['#attached']['drupalSettings']['AttachmentIntegerFormatter'][$entity_id] = $entity_id;
return $elements;
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.