OpignoEvaluationMethodFormatter.php in Opigno module 3.x
Same filename and directory in other branches
File
ActivityTypes/opigno_file_upload/src/Plugin/Field/FieldFormatter/OpignoEvaluationMethodFormatter.phpView source
<?php
namespace Drupal\opigno_file_upload\Plugin\Field\FieldFormatter;
use Drupal\Component\Utility\Html;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
/**
* Plugin implementation of the 'opigno_evaluation_method_formatter' formatter.
*
* @FieldFormatter(
* id = "opigno_evaluation_method_formatter",
* label = @Translation("Evaluation method formatter"),
* field_types = {
* "opigno_evaluation_method"
* }
* )
*/
class OpignoEvaluationMethodFormatter extends FormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
foreach ($items as $delta => $item) {
$elements[$delta] = [
'#markup' => $this
->viewValue($item),
];
}
return $elements;
}
/**
* Generate the output appropriate for one field item.
*
* @param \Drupal\Core\Field\FieldItemInterface $item
* One field item.
*
* @return string
* The textual output generated.
*/
protected function viewValue(FieldItemInterface $item) {
// The text value has no text format assigned to it, so the user input
// should equal the output, including newlines.
return nl2br(Html::escape($item->value));
}
}
Classes
Name | Description |
---|---|
OpignoEvaluationMethodFormatter | Plugin implementation of the 'opigno_evaluation_method_formatter' formatter. |