Skip to content
Snippets Groups Projects
Commit 3445e724 authored by Demian Katz's avatar Demian Katz
Browse files

Abstracted use of exit() to make a cleaner solution easier to implement in the future.

parent ea7e6070
No related merge requests found
...@@ -71,4 +71,26 @@ class AbstractBase extends AbstractActionController ...@@ -71,4 +71,26 @@ class AbstractBase extends AbstractActionController
echo "Without it, inappropriate default settings may be loaded.\n\n"; echo "Without it, inappropriate default settings may be loaded.\n\n";
} }
} }
/**
* Indicate failure.
*
* @return void
*/
protected function getFailureResponse()
{
// TODO: better framework integration for response codes
exit(1);
}
/**
* Indicate success.
*
* @return void
*/
protected function getSuccessResponse()
{
// TODO: better framework integration for response codes
exit(0);
}
} }
\ No newline at end of file
...@@ -72,7 +72,7 @@ class ImportController extends AbstractBase ...@@ -72,7 +72,7 @@ class ImportController extends AbstractBase
. "SolrAuth to load authority records.\n\n" . "SolrAuth to load authority records.\n\n"
. "Note: See vudl.properties and ojs.properties for configuration " . "Note: See vudl.properties and ojs.properties for configuration "
. "examples.\n"; . "examples.\n";
exit(1); return $this->getFailureResponse();
} }
// Try to import the document if successful: // Try to import the document if successful:
...@@ -80,11 +80,11 @@ class ImportController extends AbstractBase ...@@ -80,11 +80,11 @@ class ImportController extends AbstractBase
Importer::save($argv[0], $argv[1], $index, $testMode); Importer::save($argv[0], $argv[1], $index, $testMode);
} catch (\Exception $e) { } catch (\Exception $e) {
echo "Fatal error: " . $e->getMessage() . "\n"; echo "Fatal error: " . $e->getMessage() . "\n";
exit(1); return $this->getFailureResponse();
} }
if (!$testMode) { if (!$testMode) {
echo "Successfully imported {$argv[0]}...\n"; echo "Successfully imported {$argv[0]}...\n";
} }
exit(0); return $this->getSuccessResponse();
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment