/** * Construct a data blob as an easy way of passing data around * * @param string $config path to config file * @return array: A data blob */ function makeDataBlob($config) { // Open config file and languages $config = json_decode(file_get_contents($config), true); validateConfig($config); // identify existing i18n files and load into array $langs = array(); foreach (glob(__DIR__ . '/i18n/*.json') as $filename) { if ($filename !== __DIR__ . '/i18n/qqq.json') { $langcode = substr($filename, strlen(__DIR__ . '/i18n/'), -strlen('.json')); $langs[$langcode] = $filename; } } $i18n = makeI18nBlob($langs, $config); // hardcoded ids $ids = array('publisher' => '_n42', 'contactPoint' => '_n43', 'dataset' => array('live' => 'liveData', 'dump' => 'dumpData'), 'distribution' => array('ld' => 'liveDataLD', 'api' => 'liveDataAPI', 'dump' => 'dumpDist')); // stick loaded data into blob $data = array('config' => $config, 'dumps' => null, 'i18n' => $i18n, 'ids' => $ids); return $data; }
} if (!isset($config['db_tables'])) { echo "ERROR: 'db_tables' variable missing from config file" . PHP_EOL; $result = false; } return $result; } //----------------------------------------------------------------------------- // MAIN LOOP //----------------------------------------------------------------------------- if (empty($argv[1])) { die("ERROR: missing config file"); } echo "Using config file: " . $argv[1] . PHP_EOL; $config = (include $argv[1]); if (!validateConfig($config)) { die("ERROR: Invalid config file provided"); } echo "Config file validated" . PHP_EOL; $compareStructure = true; $compareContent = true; if (!empty($argv[2])) { if ($argv[2] == "-contentOnly") { $compareStructure = false; } else { if ($argv[2] == "-structureOnly") { $compareContent = false; } else { die("Unknown parameter: " . $argv[2]); } }