Skip to content

Commit

Permalink
Merge pull request #51 from mxgross/BackupCommand
Browse files Browse the repository at this point in the history
Backup command
  • Loading branch information
mxgross committed Jan 15, 2023
2 parents b29f8d7 + f41e1cf commit b6e738d
Show file tree
Hide file tree
Showing 7 changed files with 541 additions and 287 deletions.
63 changes: 63 additions & 0 deletions Command/EasyBackupBackupCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/*
* This file is part of the EasyBackupBundle.
* All rights reserved by Maximilian Groß (www.maximiliangross.de).
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace KimaiPlugin\EasyBackupBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use KimaiPlugin\EasyBackupBundle\Service\EasyBackupService;

// the name of the command is what users type after "php bin/console"

class EasyBackupBackupCommand extends ContainerAwareCommand
{
protected static $defaultName = 'EasyBackup:backup';
// the command description shown when running "php bin/console list"
protected static $defaultDescription = 'Creates a new backup.';

private $router;
private $easyBackupService;

public function __construct(EasyBackupService $easyBackupService)
{
$this->easyBackupService = $easyBackupService;

parent::__construct();
}

protected function configure(): void
{
$this
->setName('EasyBackup:backup')
->setDescription('Creates a new backup.')
->setHelp('This command allows you to create a new backup e.g. via cronjob.');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$log = $this->easyBackupService->createBackup();

//$output->writeln($result);
$output->writeln($log);

return 0;

// or return this if some error happened during the execution
// (it's equivalent to returning int(1))
// return Command::FAILURE;

// or return this to indicate incorrect command usage; e.g. invalid options
// or missing arguments (it's equivalent to returning int(2))
// return Command::INVALID
}
}
Loading

0 comments on commit b6e738d

Please sign in to comment.