Notify.php in Backup and Migrate 8.4
File
lib/backup_migrate_core/src/Filter/Notify.php
View source
<?php
namespace BackupMigrate\Core\Filter;
use BackupMigrate\Core\Plugin\PluginBase;
use BackupMigrate\Core\Plugin\PluginCallerInterface;
use BackupMigrate\Core\Plugin\PluginCallerTrait;
use BackupMigrate\Core\Service\StashLogger;
use BackupMigrate\Core\Service\TeeLogger;
class Notify extends PluginBase implements PluginCallerInterface {
use PluginCallerTrait;
public function supportedOps() {
return [
'beforeBackup' => [
'weight' => -100000,
],
'beforeRestore' => [
'weight' => -100000,
],
];
}
protected $logstash;
public function beforeBackup() {
$this
->addLogger();
}
public function beforeRestore() {
$this
->addLogger();
}
public function backupSucceed() {
$this
->sendNotification('Backup finished sucessfully');
}
public function backupFail(Exception $e) {
}
public function restoreSucceed() {
}
public function restoreFail() {
}
protected function sendNotification($subject) {
$messages = $this->logstash
->getAll();
$body = $subject . "\n";
if (count($messages)) {
}
}
protected function addLogger() {
$services = $this
->plugins()
->services();
$logger = $services
->get('Logger');
$this->logstash = new StashLogger();
$services
->add('Logger', new TeeLogger([
$logger,
$this->logstash,
]));
$this
->plugins()
->setServiceLocator($services);
}
}