Commit 4fb64503 authored by targoo's avatar targoo

Covert default formatter to support new Drupal 8 API

parent 9a2b78b1
......@@ -2,12 +2,13 @@
/**
* @file
* Definition of Drupal\color_field\Plugin\Field\FieldFormatter\ColorFieldDefaultFormatter.
* Contains \Drupal\color_field\Plugin\Field\FieldFormatter\ColorFieldDefaultFormatter.
*/
namespace Drupal\color_field\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Field\FieldItemListInterface;
/**
* Plugin implementation of the 'color_field_default' formatter.
......@@ -15,7 +16,7 @@ use Drupal\Core\Field\FormatterBase;
* @FieldFormatter(
* id = "color_field_default",
* module = "color_field",
* label = @Translation("Color Hex Formatter"),
* label = @Translation("Default"),
* field_types = {
* "color_field"
* }
......@@ -26,13 +27,15 @@ class ColorFieldDefaultFormatter extends FormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(EntityInterface $entity, $langcode, array $items) {
public function viewElements(FieldItemListInterface $items) {
$elements = array();
$settings = $this->getFieldSettings();
$alfa = $this->getSetting('alfa');
foreach ($items as $delta => $item) {
// The text value has no text format assigned to it, so the user input
// should equal the output, including newlines.
$elements[$delta] = array('#markup' => $item['rgb']);
$output = $item->value;
$elements[$delta] = array('#markup' => $output);
}
return $elements;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment