feeds_jsonpath_parser.module in Feeds JSONPath Parser 7
File
feeds_jsonpath_parser.module
View source
<?php
define('FEEDS_JSONPATH_PARSER_LIBRARY_VERSION', '0.5.0');
function feeds_jsonpath_parser_feeds_plugins() {
$path = drupal_get_path('module', 'feeds_jsonpath_parser');
$info = array();
$info['FeedsJSONPathParser'] = array(
'name' => t('JSONPath parser'),
'description' => t('Parse JSON using JSONPath.'),
'handler' => array(
'parent' => 'FeedsParser',
'class' => 'FeedsJSONPathParser',
'file' => 'FeedsJSONPathParser.inc',
'path' => $path,
),
);
return $info;
}
function feeds_jsonpath_parser_enable() {
cache_clear_all('plugins:feeds:plugins', 'cache');
}
function feeds_jsonpath_parser_libraries_info() {
$libraries = array();
$libraries['jsonpath'] = array(
'name' => 'JSONPath',
'vendor url' => 'https://github.com/FlowCommunications/JSONPath',
'download url' => 'https://github.com/FlowCommunications/JSONPath/archive/' . FEEDS_JSONPATH_PARSER_LIBRARY_VERSION . '.tar.gz',
'version' => FEEDS_JSONPATH_PARSER_LIBRARY_VERSION,
'xautoload' => '_feeds_jsonpath_parser_xautoload_callback',
);
return $libraries;
}
function _feeds_jsonpath_parser_xautoload_callback($adapter) {
try {
$adapter
->composerJson('composer.json');
} catch (Exception $e) {
drupal_set_message($e
->getMessage(), 'error', FALSE);
}
}
function feeds_jsonpath_parser_load_library() {
if (!class_exists('\\Flow\\JSONPath\\JSONPath', TRUE)) {
if (!module_exists('libraries')) {
return FALSE;
}
$library = libraries_load('jsonpath');
if ($library['loaded'] === FALSE) {
return FALSE;
}
if (!class_exists('\\Flow\\JSONPath\\JSONPath', TRUE)) {
return FALSE;
}
}
return TRUE;
}