You are here

public function FormatterExtrasManager::invoke in Custom Formatters 8.3

Invoke method on specified extras plugin.

File

src/FormatterExtrasManager.php, line 45

Class

FormatterExtrasManager
Class FormatterExtrasManager.

Namespace

Drupal\custom_formatters

Code

public function invoke($plugin_id, $method, FormatterInterface $entity) {
  $args = func_get_args();
  array_shift($args);
  array_shift($args);
  array_shift($args);
  $definitions = $this
    ->getDefinitions();
  if (isset($definitions[$plugin_id])) {
    $extra = $this
      ->createInstance($plugin_id, [
      'entity' => $entity,
    ]);
    if (method_exists($extra, $method)) {
      return empty($args) ? $extra
        ->{$method}() : call_user_func_array([
        $extra,
        $method,
      ], $args);
    }
  }
  return FALSE;
}