-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stefan Lindecke
committed
Sep 27, 2019
1 parent
ef72a8c
commit 45da647
Showing
3 changed files
with
69 additions
and
6 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,65 @@ | ||
<?php | ||
|
||
namespace lindesbs\climan\Command; | ||
|
||
use Contao\System; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Finder\Finder; | ||
use Symfony\Component\VarDumper\VarDumper; | ||
use Symfony\Component\Filesystem\Exception\IOExceptionInterface; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
|
||
class CliManDBCommand extends Command | ||
{ | ||
|
||
|
||
protected function configure(): void | ||
{ | ||
$this->setName('climan:db'); | ||
$this->setDescription('db stuff'); | ||
|
||
$this->addArgument("generate"); | ||
$this->addOption('gzip', null, InputOption::VALUE_NONE, 'gzip'); | ||
$this->addOption('gi', null, InputOption::VALUE_NONE, 'add generation info to filename'); | ||
|
||
} | ||
|
||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
|
||
if ($input->getArgument("generate")) | ||
{ | ||
|
||
$param = System::getContainer()->get('database_connection')->getParams(); | ||
|
||
|
||
$db = new \mysqli($param['host'], $param['user'], $param['password'], $param['dbname'], $param['port']); | ||
$dump = new \MySQLDump($db); | ||
|
||
$strFilename = "export.sql"; | ||
|
||
|
||
if ($input->getOption("gi")) | ||
{ | ||
$strFilename = sprintf("export_%s.sql", date("Y-m-d_H-i-s")); | ||
} | ||
|
||
if ($input->getOption("gzip")) | ||
{ | ||
$strFilename.=".gz"; | ||
} | ||
|
||
$dump->save(TL_ROOT . '/'.$strFilename); | ||
|
||
return; | ||
} | ||
|
||
} | ||
|
||
|
||
} |
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
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