-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0321ab
commit 647e2ac
Showing
19 changed files
with
244 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,15 +25,17 @@ | |
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\NullOutput; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Base class for all OAI-PMH console commands. | ||
* | ||
* @author Sebastian Meyer <[email protected]> | ||
* @package opencultureconsulting/oai-pmh2 | ||
*/ | ||
abstract class ConsoleCommand extends Command | ||
abstract class Console extends Command | ||
{ | ||
/** | ||
* Clears the result cache. | ||
|
@@ -76,4 +78,43 @@ protected function getMemoryLimit(): int | |
} | ||
return $limit; | ||
} | ||
|
||
/** | ||
* Validate input arguments. | ||
* | ||
* @param InputInterface $input The inputs | ||
* @param OutputInterface $output The output interface | ||
* | ||
* @return bool Whether the inputs validate | ||
*/ | ||
protected function validateInput(InputInterface $input, OutputInterface $output): bool | ||
{ | ||
/** @var array<string, string> */ | ||
$arguments = $input->getArguments(); | ||
|
||
$formats = Database::getInstance()->getMetadataFormats()->getQueryResult(); | ||
if (!in_array($arguments['format'], array_keys($formats), true)) { | ||
$output->writeln([ | ||
'', | ||
sprintf( | ||
' [ERROR] Metadata format "%s" is not supported. ', | ||
$arguments['format'] | ||
), | ||
'' | ||
]); | ||
return false; | ||
} | ||
if (!is_readable($arguments['file'])) { | ||
$output->writeln([ | ||
'', | ||
sprintf( | ||
' [ERROR] File "%s" not found or not readable. ', | ||
$arguments['file'] | ||
), | ||
'' | ||
]); | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.