|
|
|
|
@@ -11,6 +11,33 @@ final class MDImporterMissingConcordance extends Exception {
|
|
|
|
|
|
|
|
|
|
/** @var array<string, array<string>> */
|
|
|
|
|
private static array $_missing_concordances = [];
|
|
|
|
|
public static bool $suppress_shutdown_function = false;
|
|
|
|
|
private static bool $_shutdown_function_registered = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the text for registering shutdown functions.
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public static function getCleanMissingConcordanceReport():string {
|
|
|
|
|
|
|
|
|
|
if (empty(self::$_missing_concordances)) return '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$output = PHP_EOL . PHP_EOL . "There are unmapped concordances. Please map them before proceeding." . PHP_EOL . "You may use https://concordance.museum-digital.org/ to do the mapping" . PHP_EOL . PHP_EOL;
|
|
|
|
|
foreach (self::$_missing_concordances as $key => $values) {
|
|
|
|
|
sort($values);
|
|
|
|
|
$output .= PHP_EOL . PHP_EOL . $key . PHP_EOL . PHP_EOL;
|
|
|
|
|
$output .= implode(PHP_EOL, array_unique($values));
|
|
|
|
|
}
|
|
|
|
|
$output .= PHP_EOL;
|
|
|
|
|
|
|
|
|
|
// Reset missing concordance report.
|
|
|
|
|
self::$_missing_concordances = [];
|
|
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets up an error.
|
|
|
|
|
@@ -24,17 +51,14 @@ final class MDImporterMissingConcordance extends Exception {
|
|
|
|
|
|
|
|
|
|
if (class_exists("MD_IMPORTER_CONF") && MD_IMPORTER_CONF::$dry_run === true) {
|
|
|
|
|
|
|
|
|
|
if (empty(self::$_missing_concordances)) {
|
|
|
|
|
if (self::$_shutdown_function_registered === false) {
|
|
|
|
|
|
|
|
|
|
// Register printing at the end
|
|
|
|
|
register_shutdown_function(function() {
|
|
|
|
|
echo PHP_EOL . PHP_EOL . "There are unmapped concordances. Please map them before proceeding." . PHP_EOL . "You may use https://concordance.museum-digital.org/ to do the mapping" . PHP_EOL . PHP_EOL;
|
|
|
|
|
foreach (self::$_missing_concordances as $key => $values) {
|
|
|
|
|
sort($values);
|
|
|
|
|
echo PHP_EOL . PHP_EOL . $key . PHP_EOL . PHP_EOL;
|
|
|
|
|
echo implode(PHP_EOL, array_unique($values));
|
|
|
|
|
}
|
|
|
|
|
if (self::$suppress_shutdown_function === true) return;
|
|
|
|
|
echo self::getCleanMissingConcordanceReport();
|
|
|
|
|
});
|
|
|
|
|
self::$_shutdown_function_registered = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|