public function WebformSourceEntityManager::getSourceEntity in Webform 8.5
Same name and namespace in other branches
- 6.x src/Plugin/WebformSourceEntityManager.php \Drupal\webform\Plugin\WebformSourceEntityManager::getSourceEntity()
Detect and return a source entity from current context.
Parameters
string|string[] $ignored_types: Entity types that may not be used as a source entity.
Return value
\Drupal\Core\Entity\EntityInterface|null Source entity or NULL when no source entity is found.
Overrides WebformSourceEntityManagerInterface::getSourceEntity
File
- src/
Plugin/ WebformSourceEntityManager.php, line 79
Class
- WebformSourceEntityManager
- Webform source entity plugin manager.
Namespace
Drupal\webform\PluginCode
public function getSourceEntity($ignored_types = []) {
if (!is_array($ignored_types)) {
$ignored_types = [
$ignored_types,
];
}
foreach ($this
->getDefinitions() as $plugin_id => $definition) {
/** @var WebformSourceEntityInterface $instance */
$instance = $this
->createInstance($plugin_id);
$source_entity = $instance
->getSourceEntity($ignored_types);
if ($source_entity) {
return $source_entity;
}
}
return NULL;
}