You are here

public function JmesRuntimeFactory::createRuntime in Feeds extensible parsers 8

Creates a runtime object.

Parameters

string $type: (optional) The type of Runtime to create.

Overrides JmesRuntimeFactoryInterface::createRuntime

File

src/JmesRuntimeFactory.php, line 19

Class

JmesRuntimeFactory
Defines a factory for generating JMESPath runtime objects.

Namespace

Drupal\feeds_ex

Code

public function createRuntime($type = NULL) {
  switch ($type) {
    case static::AST:
      return $this
        ->createAstRuntime();
    case static::COMPILER:
    default:
      try {
        return $this
          ->createCompilerRuntime(\Drupal::service('file_system')
          ->realpath($this
          ->getCompileDirectory()));
      } catch (RuntimeException $e) {

        // Fallback to AstRuntime if creating a CompilerRuntime failed.
        return $this
          ->createRuntime(static::AST);
      }
  }
}