You are here

public function FormatterBase::view in Blazy 7

Implements hook_field_formatter_view().

File

src/Plugin/Field/FieldFormatter/FormatterBase.php, line 191

Class

FormatterBase
Base class for blazy/slick image, and file formatters.

Namespace

Drupal\blazy\Plugin\Field\FieldFormatter

Code

public function view($items, $langcode, $entity_type, $entity, $display) {
  list($entity_id) = entity_extract_ids($entity_type, $entity);

  // Simplify relevant function arguments into settings array.
  $this->fieldDisplay = $display;
  $this->entity = $entity;
  $settings = $this
    ->setupFieldVariables();
  $settings['entity_id'] = $entity_id;
  $this->langcode = $settings['langcode'] = $langcode;

  // Gets view_mode from formatter_view.
  $this->viewMode = isset($settings['current_view_mode']) ? $settings['current_view_mode'] : 'default';
  $this
    ->setHtmlSettings($settings);
  return $this
    ->viewElements($items, $entity);
}