function ElementInfoManager::fromClass
Creates a render object based on the provided class and configuration.
@template T of ElementInterface
Parameters
class-string<T> $class: The class of the render object being instantiated.
array $configuration: An array of configuration relevant to the render object.
Return value
T A fully configured render object.
Overrides ElementInfoManagerInterface::fromClass
File
-
core/
lib/ Drupal/ Core/ Render/ ElementInfoManager.php, line 245
Class
- ElementInfoManager
- Provides a plugin manager for element plugins.
Namespace
Drupal\Core\RenderCode
public function fromClass(string $class, array $configuration = []) : ElementInterface {
$this->getDefinitions();
if ($id = $this->getIdFromClass($class)) {
return $this->createInstance($id, $configuration);
}
throw new \LogicException("{$class} is not a valid element class.");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.