-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRemoveLocalBackupHandler.php
32 lines (27 loc) · 1.08 KB
/
RemoveLocalBackupHandler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace DigipolisGent\Robo\Helpers\EventHandler\DefaultHandler;
use DigipolisGent\CommandBuilder\CommandBuilder;
use DigipolisGent\Robo\Helpers\EventHandler\AbstractBackupHandler;
use DigipolisGent\Robo\Helpers\Util\RemoteConfig;
use Symfony\Component\EventDispatcher\GenericEvent;
class RemoveLocalBackupHandler extends AbstractBackupHandler
{
/**
* {@inheritDoc}
*/
public function handle(GenericEvent $event)
{
/** @var RemoteConfig $remoteConfig */
$remoteConfig = $event->getArgument('remoteConfig');
$remoteSettings = $remoteConfig->getRemoteSettings();
$options = $event->getArgument('options');
$dbBackupFile = $this->backupFileName('.sql.gz', $remoteSettings['time']);
$removeLocalBackup = CommandBuilder::create('rm')
->addFlag('f')
->addArgument($dbBackupFile);
if ($options['files']) {
$removeLocalBackup->addArgument($this->backupFileName('.tar.gz', $remoteSettings['time']));
}
return $this->taskExecStack()->exec((string) $removeLocalBackup);
}
}