You are here

public function WebformElementManager::invokeMethod in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElementManager.php \Drupal\webform\Plugin\WebformElementManager::invokeMethod()

Invoke a method for a Webform 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 WebformElementManagerInterface::invokeMethod

See also

\Drupal\webform\WebformSubmissionForm::prepareElements

File

src/Plugin/WebformElementManager.php, line 224

Class

WebformElementManager
Provides a plugin manager for webform element plugins.

Namespace

Drupal\webform\Plugin

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\webform\Plugin\WebformElementInterface $webform_element */
  $webform_element = $this
    ->createInstance($plugin_id);
  return $webform_element
    ->{$method}($element, $context1, $context2);
}