Skip to content

Commit

Permalink
FEATURE: reworked exit condition
Browse files Browse the repository at this point in the history
* changed from 'exit' to '$this->quit(1)'
* slightly edited phpDoc

ISSUE: neos#3086
  • Loading branch information
Jan3k3y authored and ahaeslich committed Apr 4, 2023
1 parent e4e1c1c commit a1da670
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Neos.Media/Classes/Command/MediaCommandController.php
Expand Up @@ -20,6 +20,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;
use Neos\Flow\Cli\Exception\StopCommandException;
use Neos\Flow\Persistence\Exception\IllegalObjectTypeException;
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Flow\Reflection\ReflectionService;
Expand Down Expand Up @@ -418,9 +419,11 @@ public function renderThumbnailsCommand(int $limit = null, bool $quiet = false)
* @param string $assetSource If specified, only assets of this asset source are considered. For example "neos" or "my-asset-management-system".
* @param bool $quiet If set, only errors and questions will be displayed.
* @param bool $assumeYes If set, "yes" is assumed for the "shall I remove ..." dialog.
* @param bool $filterCroppedVariants Find custom crops but have to check if used (slow).
* @param bool $filterCroppedVariants Find custom cropped variants but have to check if used (slow).
* @param int|null $limit Limit the result of unused assets displayed and removed for this run.
* @param string $presetIdentifier If specified, only presets with this identifier are observed.
*
* @throws StopCommandException
*/
public function removeOutdatedVariantsCommand(bool $quiet = false, bool $assumeYes = false, bool $filterCroppedVariants = false, int $limit = null, string $assetSource = '', string $presetIdentifier = '')
{
Expand All @@ -434,7 +437,7 @@ public function removeOutdatedVariantsCommand(bool $quiet = false, bool $assumeY

if (empty($currentPresets)) {
!$quiet && $this->output->outputLine(PHP_EOL . PHP_EOL . '<em>No presets found.</em>');
exit;
$this->quit(1);
}

$filterByAssetSourceIdentifier = $assetSource;
Expand All @@ -449,7 +452,7 @@ public function removeOutdatedVariantsCommand(bool $quiet = false, bool $assumeY
$variants = $this->imageVariantRepository->findAllWithOutdatedPresets($currentPresets, !empty($presetIdentifier), $filterCroppedVariants, $limit);
if (empty($variants)) {
!$quiet && $this->output->outputLine(PHP_EOL . PHP_EOL . '<em>No variants found.</em>');
exit;
$this->quit(1);
}

$outdatedVariants = [];
Expand Down Expand Up @@ -488,7 +491,7 @@ public function removeOutdatedVariantsCommand(bool $quiet = false, bool $assumeY

if (empty($outdatedVariants)) {
!$quiet && $this->output->outputLine(PHP_EOL . PHP_EOL . '<em>No outdated variants found.</em>');
exit;
$this->quit(1);
}

if (!$quiet) {
Expand Down Expand Up @@ -516,7 +519,7 @@ public function removeOutdatedVariantsCommand(bool $quiet = false, bool $assumeY
}
if (!$this->output->askConfirmation(PHP_EOL . 'Do you want to remove all variants with outdated presets? [Y,n] ')) {
$this->output->outputLine(PHP_EOL . '<em>No variants have been deleted...</em>');
exit;
$this->quit(1);
}
}

Expand Down Expand Up @@ -546,7 +549,7 @@ public function removeOutdatedVariantsCommand(bool $quiet = false, bool $assumeY
} catch (IllegalObjectTypeException $e) {
$this->output->outputLine(PHP_EOL . 'Unable to remove %s: "%s"', [get_class($variantToRemove), $variantToRemove->getTitle()]);
$this->output->outputLine(PHP_EOL . $e->getMessage());
exit;
$this->quit(1);
}

$outdatedVariantSize += $variantSize;
Expand Down

0 comments on commit a1da670

Please sign in to comment.