Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Environment.php

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

Twig

Code

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));
}
RSS feed
Powered by Drupal