ApplyMigrationsForm: new form, just a button
This commit is contained in:
parent
7279fd7c40
commit
2ab802dcdb
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Module\Director\Db\Migrations;
|
||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||
|
||||
class ApplyMigrationsForm extends QuickForm
|
||||
{
|
||||
protected $migrations;
|
||||
|
||||
public function setup()
|
||||
{
|
||||
$this->setSubmitLabel($this->translate('Apply schema migrations'));
|
||||
}
|
||||
|
||||
public function onSuccess()
|
||||
{
|
||||
try {
|
||||
$this->setSuccessMessage($this->translate(
|
||||
'Pending database schema migrations have successfully been applied'
|
||||
));
|
||||
|
||||
$this->migrations->applyPendingMigrations();
|
||||
parent::onSuccess();
|
||||
} catch (Exception $e) {
|
||||
$this->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function setMigrations(Migrations $migrations)
|
||||
{
|
||||
$this->migrations = $migrations;
|
||||
return $this;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue