You are here

trait FormElementCallbackTrait in Currency 8.3

Hierarchy

2 files declare their use of FormElementCallbackTrait
CurrencyAmount.php in src/Element/CurrencyAmount.php
CurrencySign.php in src/Element/CurrencySign.php

File

src/FormElementCallbackTrait.php, line 5

Namespace

Drupal\currency
View source
trait FormElementCallbackTrait {

  /**
   * Instantiates this class as a plugin and calls a method on it.
   */
  public static function __callStatic($name, array $arguments) {
    if (preg_match('/^instantiate#(.+?)#(.+?)$/', $name)) {
      list(, $method, $plugin_id) = explode('#', $name);

      /** @var \Drupal\Component\Plugin\PluginManagerInterface $element_info_manager */
      $element_info_manager = \Drupal::service('plugin.manager.element_info');

      /** @var \Drupal\currency\Element\CurrencyAmount $element_plugin */
      $element_plugin = $element_info_manager
        ->createInstance($plugin_id);
      return call_user_func_array([
        $element_plugin,
        $method,
      ], $arguments);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FormElementCallbackTrait::__callStatic public static function Instantiates this class as a plugin and calls a method on it.