13 use Symfony\Component\Console\Command\Command;
14 use Symfony\Component\Console\Helper\TableFactory;
15 use Symfony\Component\Console\Input\InputInterface;
16 use Symfony\Component\Console\Output\OutputInterface;
36 private $directoryList;
41 private $tableHelperFactory;
51 TableFactory $tableHelperFactory =
null 53 $this->directoryList = $directoryList;
56 parent::__construct();
64 $this->setName(
'info:backups:list')
65 ->setDescription(
'Prints list of available backup files');
73 protected function execute(InputInterface $input, OutputInterface
$output)
77 if ($this->file->isExists($backupsDir)) {
78 $contents = $this->file->readDirectoryRecursively($backupsDir);
81 $partsOfPath = explode(
'/', str_replace(
'\\',
'/',
$path));
82 $fileName = $partsOfPath[count($partsOfPath) - 1];
85 $filenameWithoutExtension = explode(
'.',
$fileName);
88 $fileNameParts = explode(
'_', $filenameWithoutExtension[0]);
93 }
elseif (in_array(
'code', $fileNameParts)) {
98 if (empty($tempTable)) {
99 $output->writeln(
'<info>No backup files found.</info>');
100 return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
102 $output->writeln(
"<info>Showing backup files in $backupsDir.</info>");
104 $tableHelper = $this->tableHelperFactory->create([
'output' =>
$output]);
105 $tableHelper->setHeaders([
'Backup Filename',
'Backup Type']);
107 foreach ($tempTable as $key =>
$value) {
108 $tableHelper->addRow([$key,
$value]);
110 $tableHelper->render();
112 $output->writeln(
'<info>No backup files found.</info>');
115 return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
elseif(isset( $params[ 'redirect_parent']))
const DEFAULT_BACKUP_DIRECTORY
__construct(DirectoryList $directoryList, File $file, TableFactory $tableHelperFactory=null)