You are here

public function YamlFormElementManager::invokeMethod in YAML Form 8

Invoke a method for specific FAPI element.

Parameters

string $method: The method name.

array $element: An associative array containing an element with a #type property.

mixed $context1: (optional) An additional variable that is passed by reference.

mixed $context2: (optional) An additional variable that is passed by reference. If more context needs to be provided to implementations, then this should be an associative array as described above.

Return value

mixed|null Return result of the invoked method. NULL will be returned if the element and/or method name does not exist.

Overrides YamlFormElementManagerInterface::invokeMethod

File

src/YamlFormElementManager.php, line 97

Class

YamlFormElementManager
Provides a plugin manager for form element plugins.

Namespace

Drupal\yamlform

Code

public function invokeMethod($method, array &$element, &$context1 = NULL, &$context2 = NULL) {

  // Make sure element has a #type.
  if (!isset($element['#type'])) {
    return NULL;
  }
  $plugin_id = $this
    ->getElementPluginId($element);

  /** @var \Drupal\yamlform\YamlFormElementInterface $yamlform_element */
  $yamlform_element = $this
    ->createInstance($plugin_id);
  return $yamlform_element
    ->{$method}($element, $context1, $context2);
}