protected function FeedsExJmesPath::createRuntime in Feeds extensible parsers 7
Creates a runtime object.
Checks for different versions of JMESPath.php.
Parameters
string $directory: The compile directory.
Return value
object An invokable runtime object.
1 call to FeedsExJmesPath::createRuntime()
- FeedsExJmesPath::search in src/
FeedsExJmesPath.inc - Returns data from the input array that matches a JMESPath expression.
File
- src/
FeedsExJmesPath.inc, line 122 - Contains FeedsExJmesPath.
Class
- FeedsExJmesPath
- Parses JSON documents with JMESPath.
Code
protected function createRuntime($directory) {
// Version 2.
if (class_exists('JmesPath\\AstRuntime')) {
try {
$runtime = new CompilerRuntime2($directory);
} catch (RuntimeException $e) {
$runtime = new AstRuntime2();
}
}
elseif (class_exists('JmesPath\\Runtime\\AstRuntime')) {
try {
$runtime = new CompilerRuntime1(array(
'dir' => $directory,
));
} catch (RuntimeException $e) {
$runtime = new AstRuntime1();
}
$runtime = new FeedsExJmesPathV1Wrapper($runtime);
}
else {
throw new RuntimeException(t('JMESPath.php is not installed correctly.'));
}
return $runtime;
}