You are here

public function FormatterPlugin::getActiveFormatter in Blazy 7

Return the uncached formatter based on the field type.

1 call to FormatterPlugin::getActiveFormatter()
FormatterPlugin::getFormatter in src/Plugin/Field/FieldFormatter/FormatterPlugin.php
Return the cached formatter based on the field type.

File

src/Plugin/Field/FieldFormatter/FormatterPlugin.php, line 72

Class

FormatterPlugin
Blazy formatter plugin initializer.

Namespace

Drupal\blazy\Plugin\Field\FieldFormatter

Code

public function getActiveFormatter($type, $field, $instance, $namespace = 'blazy') {
  $plugin_id = $namespace . '_' . $type;
  foreach ($this
    ->formatterInfo() as $key => $info) {
    if ($key == $plugin_id && !empty($info['class'])) {
      $class = $info['class'];
      return new $class($plugin_id, $field, $instance, $this->formatter, $this->manager);
    }
  }
  return FALSE;
}