class Notify in Backup and Migrate 8.4
Class Notify
Notifies by email when a backup succeeds or fails.
@package BackupMigrate\Core\Filter
Hierarchy
- class \BackupMigrate\Core\Plugin\PluginBase implements ConfigurableInterface, PluginInterface uses ConfigurableTrait
- class \BackupMigrate\Core\Filter\Notify implements PluginCallerInterface uses PluginCallerTrait
Expanded class hierarchy of Notify
File
- lib/
backup_migrate_core/ src/ Filter/ Notify.php, line 18
Namespace
BackupMigrate\Core\FilterView source
class Notify extends PluginBase implements PluginCallerInterface {
use PluginCallerTrait;
/**
* Add a weight so that our before* operations run before any other plugin has
* a chance to write any log entries.
*
* @return array
*/
public function supportedOps() {
return [
'beforeBackup' => [
'weight' => -100000,
],
'beforeRestore' => [
'weight' => -100000,
],
];
}
/**
* @var StashLogger
*/
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() {
}
/**
* @param $subject
* @param $body
* @param $messages
*/
protected function sendNotification($subject) {
$messages = $this->logstash
->getAll();
$body = $subject . "\n";
if (count($messages)) {
}
// $body .=
}
/**
* add our stash logger to the service locator to capture all logged messages.
*/
protected function addLogger() {
$services = $this
->plugins()
->services();
// Get the current logger.
$logger = $services
->get('Logger');
// Create a new stash logger to save messages.
$this->logstash = new StashLogger();
// Add a tee to send logs to both the regular logger and our stash.
$services
->add('Logger', new TeeLogger([
$logger,
$this->logstash,
]));
// Add the services back into the plugin manager to re-inject existing plugins
$this
->plugins()
->setServiceLocator($services);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurableTrait:: |
protected | property | The object's configuration object. | |
ConfigurableTrait:: |
protected | property | The initial configuration. These configuration options can be overriden by the config options but will not be overwritten. If the object is re-configured after construction any missing configuration options will revert to these values. | |
ConfigurableTrait:: |
public | function | Get a specific value from the configuration. | |
ConfigurableTrait:: |
public | function | Get the configuration object for this item. | |
ConfigurableTrait:: |
public | function | Get the default values for the plugin. | 10 |
ConfigurableTrait:: |
public | function | Get any validation errors in the config. | |
ConfigurableTrait:: |
public | function | Get a default (blank) schema. | 10 |
ConfigurableTrait:: |
public | function | Set the configuration for all plugins. | 1 |
ConfigurableTrait:: |
public | function | 2 | |
Notify:: |
protected | property | ||
Notify:: |
protected | function | add our stash logger to the service locator to capture all logged messages. | |
Notify:: |
public | function | ||
Notify:: |
public | function | ||
Notify:: |
public | function | ||
Notify:: |
public | function | ||
Notify:: |
public | function | ||
Notify:: |
public | function | ||
Notify:: |
protected | function | ||
Notify:: |
public | function |
Add a weight so that our before* operations run before any other plugin has
a chance to write any log entries. Overrides PluginBase:: |
|
PluginBase:: |
public | function |
What is the weight of the given operation for this plugin. Overrides PluginInterface:: |
|
PluginBase:: |
public | function |
Does this plugin implement the given operation. Overrides PluginInterface:: |
|
PluginCallerTrait:: |
protected | property | ||
PluginCallerTrait:: |
public | function | Get the plugin manager. | |
PluginCallerTrait:: |
public | function | Inject the plugin manager. | |
TranslatableTrait:: |
protected | property | ||
TranslatableTrait:: |
public | function | ||
TranslatableTrait:: |
public | function | Translate the given string if there is a translator service available. |