function Environment::getRuntime
Returns the runtime implementation of a Twig element (filter/function/tag/test).
@template TRuntime of object
Parameters
class-string<TRuntime> $class A runtime class name:
Return value
TRuntime The runtime implementation
Throws
RuntimeError When the template cannot be found
File
-
vendor/
twig/ twig/ src/ Environment.php, line 634
Class
- Environment
- Stores the Twig configuration and renders templates.
Namespace
TwigCode
public function getRuntime(string $class) {
if (isset($this->runtimes[$class])) {
return $this->runtimes[$class];
}
foreach ($this->runtimeLoaders as $loader) {
if (null !== ($runtime = $loader->load($class))) {
return $this->runtimes[$class] = $runtime;
}
}
if (null !== ($runtime = $this->defaultRuntimeLoader
->load($class))) {
return $this->runtimes[$class] = $runtime;
}
throw new RuntimeError(\sprintf('Unable to load the "%s" runtime.', $class));
}