-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from mxgross/BackupCommand
Backup command
- Loading branch information
Showing
7 changed files
with
541 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.