128 lines
3.5 KiB
PHP
Executable File
128 lines
3.5 KiB
PHP
Executable File
<?php namespace GromIT\MysqlBackup;
|
|
|
|
use Backend\Facades\Backend;
|
|
use Gromit\MysqlBackup\Console\RunBackup;
|
|
use Gromit\MysqlBackup\Models\MysqlBackupSettings;
|
|
use System\Classes\PluginBase;
|
|
|
|
/**
|
|
* mysqlbackup Plugin Information File
|
|
*/
|
|
class Plugin extends PluginBase
|
|
{
|
|
/**
|
|
* Returns information about this plugin.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function pluginDetails()
|
|
{
|
|
return [
|
|
'name' => 'mysqlbackup',
|
|
'description' => 'Plugin for OctoberCMS, which allows you to make backups mysql-database',
|
|
'author' => 'GromIT',
|
|
'icon' => 'icon-database'
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Register method, called when the plugin is first registered.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
$this->registerConsoleCommand('mysqlbackup:run', RunBackup::class);
|
|
}
|
|
|
|
/**
|
|
* Register schedule tasks.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function registerSchedule($schedule)
|
|
{
|
|
$schedule->command('mysqlbackup:run')->cron(MysqlBackupSettings::getCronExpression())->when(function () {
|
|
if (!is_null(MysqlBackupSettings::getCronExpression())) {
|
|
return true;
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Boot method, called right before the request route.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function boot()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Registers any front-end components implemented in this plugin.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function registerComponents()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Registers any back-end permissions used by this plugin.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function registerPermissions()
|
|
{
|
|
return [
|
|
'gromit.mysqlbackup.access_settings' => [
|
|
'tab' => 'MysqlBackup',
|
|
'label' => trans('gromit.mysqlbackup::lang.permission'),
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Registers back-end navigation items for this plugin.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function registerNavigation()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Registers support plugin settings.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function registerSettings()
|
|
{
|
|
return [
|
|
'backupSettings' => [
|
|
'label' => trans('gromit.mysqlbackup::lang.sidebar.settings_title'),
|
|
'description' => trans('gromit.mysqlbackup::lang.sidebar.settings_description'),
|
|
'category' => trans('gromit.mysqlbackup::lang.sidebar.category'),
|
|
'icon' => 'icon-cog',
|
|
'class' => MysqlBackupSettings::class,
|
|
'order' => 100,
|
|
'keywords' => 'backup database mysql',
|
|
'permissions' => ['gromit.mysqlbackup.access_settings']
|
|
],
|
|
'backups' => [
|
|
'label' => trans('gromit.mysqlbackup::lang.sidebar.list_title'),
|
|
'description' => trans('gromit.mysqlbackup::lang.sidebar.list_description'),
|
|
'category' => trans('gromit.mysqlbackup::lang.sidebar.category'),
|
|
'icon' => 'icon-database',
|
|
'url' => Backend::url('gromit/mysqlbackup/mysqlbackups'),
|
|
'order' => 100,
|
|
'keywords' => 'backup database mysql',
|
|
'permissions' => ['gromit.mysqlbackup.access_settings']
|
|
]
|
|
];
|
|
}
|
|
}
|