/**
* Internal function to execute the command.
*
* @param InputInterface $input The input to inject into the command.
* @param OutputInterface $output The output to inject into the command.
*
* @return integer The command exit code
*
* @since 4.0.0
*/
protected function doExecute(InputInterface $input, OutputInterface $output) : int
{
$symfonyStyle = new SymfonyStyle($input, $output);
$symfonyStyle->title('Running Session Garbage Collection');
$session = $this->getSessionService($input->getOption('application'));
$gcResult = $session->gc();
// Destroy the session started for this process
$session->destroy();
if ($gcResult === false) {
$symfonyStyle->error('Garbage collection was not completed. Either the operation failed or it is not supported on your platform.');
return Command::FAILURE;
}
$symfonyStyle->success('Garbage collection completed.');
return Command::SUCCESS;
}