ApplyMigrationsForm: new form, just a button

This commit is contained in:
Thomas Gelf 2016-05-02 10:31:31 +02:00
parent 7279fd7c40
commit 2ab802dcdb
1 changed files with 37 additions and 0 deletions

View File

@ -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;
}
}