Skip to content

Commit

Permalink
Ensure we are using Symfony 5 (#39)
Browse files Browse the repository at this point in the history
* Ensure we are using Symfony 5

* In the end we don't need it
  • Loading branch information
whikloj authored Mar 1, 2022
1 parent 042ee38 commit a6d3e28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"ext-curl": "*",
"ext-zip": "*",
"ext-mbstring": "*",
"ext-intl": "*"
"ext-intl": "*",
"symfony/console": "^5.4"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
Expand Down Expand Up @@ -58,5 +59,10 @@
"allow-plugins": {
"symfony/flex": false
}
},
"extra": {
"symfony": {
"allow-contrib": false
}
}
}
15 changes: 4 additions & 11 deletions src/Commands/ValidateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use whikloj\BagItTools\Bag;
Expand Down Expand Up @@ -40,20 +39,14 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
// TODO: This is simplified in Console 5.0, remove this then.
if ($output instanceof ConsoleOutputInterface) {
$error_io = new SymfonyStyle($input, $output->getErrorOutput());
} else {
$error_io = $io;
}

$path = $input->getArgument('bag-path');
if ($path[0] !== DIRECTORY_SEPARATOR) {
$path = getcwd() . DIRECTORY_SEPARATOR . $path;
$realpath = realpath($path);
}
if ((isset($realpath) && $realpath === false) || !file_exists($path)) {
$error_io->error("Path $path does not exist, cannot validate.");
$io->error("Path $path does not exist, cannot validate.");
} else {
try {
if (isset($realpath) && $realpath !== false) {
Expand All @@ -66,14 +59,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// Print warnings
$warnings = $bag->getWarnings();
foreach ($warnings as $warning) {
$error_io->warning("{$warning['message']} -- file: {$warning['file']}");
$io->warning("{$warning['message']} -- file: {$warning['file']}");
}
}
if ($verbose >= OutputInterface::VERBOSITY_VERBOSE) {
// Print errors
$errors = $bag->getErrors();
foreach ($errors as $error) {
$error_io->error("{$error['message']} -- file: {$error['file']}");
$io->error("{$error['message']} -- file: {$error['file']}");
}
}
if ($verbose >= OutputInterface::VERBOSITY_NORMAL) {
Expand All @@ -85,7 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
return($valid ? 0 : 1);
} catch (BagItException $e) {
$error_io->error("Exception: {$e->getMessage()}");
$io->error("Exception: {$e->getMessage()}");
}
}
return(1);
Expand Down

0 comments on commit a6d3e28

Please sign in to comment.