public function WebformElementManager::getElementInstance in Webform 8.5
Same name and namespace in other branches
- 6.x src/Plugin/WebformElementManager.php \Drupal\webform\Plugin\WebformElementManager::getElementInstance()
Get a webform element plugin instance for an element.
Parameters
array $element: An associative array containing an element with a #type property.
\Drupal\webform\WebformInterface|\Drupal\webform\WebformSubmissionInterface $entity: A webform or webform submission entity.
Return value
\Drupal\webform\Plugin\WebformElementInterface A webform element plugin instance
Throws
\Exception Throw exception if entity type is not a webform or webform submission.
Overrides WebformElementManagerInterface::getElementInstance
3 calls to WebformElementManager::getElementInstance()
- WebformElementManager::buildElement in src/
Plugin/ WebformElementManager.php - Build a Webform element.
- WebformElementManager::initializeElement in src/
Plugin/ WebformElementManager.php - Build a Webform element.
- WebformElementManager::processElement in src/
Plugin/ WebformElementManager.php - Process a form element and apply webform element specific enhancements.
File
- src/
Plugin/ WebformElementManager.php, line 257
Class
- WebformElementManager
- Provides a plugin manager for webform element plugins.
Namespace
Drupal\webform\PluginCode
public function getElementInstance(array $element, EntityInterface $entity = NULL) {
$plugin_id = $this
->getElementPluginId($element);
/** @var \Drupal\webform\Plugin\WebformElementInterface $element_plugin */
$element_plugin = $this
->createInstance($plugin_id, $element);
if ($entity) {
$element_plugin
->setEntities($entity);
}
else {
$element_plugin
->resetEntities();
}
return $element_plugin;
}