ResponsiveImageTestFormatter.php
Same filename in other branches
- 9 core/modules/responsive_image/tests/modules/responsive_image_test_module/src/Plugin/Field/FieldFormatter/ResponsiveImageTestFormatter.php
- 8.9.x core/modules/responsive_image/tests/modules/responsive_image_test_module/src/Plugin/Field/FieldFormatter/ResponsiveImageTestFormatter.php
- 10 core/modules/responsive_image/tests/modules/responsive_image_test_module/src/Plugin/Field/FieldFormatter/ResponsiveImageTestFormatter.php
Namespace
Drupal\responsive_image_test_module\Plugin\Field\FieldFormatterFile
-
core/
modules/ responsive_image/ tests/ modules/ responsive_image_test_module/ src/ Plugin/ Field/ FieldFormatter/ ResponsiveImageTestFormatter.php
View source
<?php
declare (strict_types=1);
namespace Drupal\responsive_image_test_module\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\Attribute\FieldFormatter;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\responsive_image\Plugin\Field\FieldFormatter\ResponsiveImageFormatter;
use Drupal\Core\Field\FieldItemListInterface;
/**
* Plugin to test responsive image formatter.
*/
class ResponsiveImageTestFormatter extends ResponsiveImageFormatter {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = parent::viewElements($items, $langcode);
// Unset #item_attributes to test that the theme function can handle that.
foreach ($elements as &$element) {
if (isset($element['#item_attributes'])) {
unset($element['#item_attributes']);
}
}
return $elements;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
ResponsiveImageTestFormatter | Plugin to test responsive image formatter. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.