IcingaConfig: rename fromDb to load

This commit is contained in:
Thomas Gelf 2015-12-15 16:46:19 +01:00
parent d1d9ebe412
commit 942363c65d
2 changed files with 8 additions and 7 deletions

View File

@ -13,7 +13,7 @@ class ConfigController extends ActionController
public function deployAction() public function deployAction()
{ {
$checksum = $this->params->get('checksum'); $checksum = $this->params->get('checksum');
$config = IcingaConfig::fromDb(Util::hex2binary($checksum), $this->db()); $config = IcingaConfig::load(Util::hex2binary($checksum), $this->db());
if ($this->api()->dumpConfig($config, $this->db())) { if ($this->api()->dumpConfig($config, $this->db())) {
$url = Url::fromPath('director/list/deploymentlog'); $url = Url::fromPath('director/list/deploymentlog');
Notification::success( Notification::success(
@ -48,9 +48,10 @@ class ConfigController extends ActionController
'url' => $this->getRequest()->getUrl(), 'url' => $this->getRequest()->getUrl(),
))->activate('config'); ))->activate('config');
$this->view->config = IcingaConfig::fromDb(Util::hex2binary($this->params->get('checksum')), $this->db()); $this->view->config = IcingaConfig::load(Util::hex2binary($this->params->get('checksum')), $this->db());
} }
// TODO: Check if this can be removed
public function storeAction() public function storeAction()
{ {
$config = IcingaConfig::generate($this->db()); $config = IcingaConfig::generate($this->db());

View File

@ -2,8 +2,8 @@
namespace Icinga\Module\Director\IcingaConfig; namespace Icinga\Module\Director\IcingaConfig;
use Icinga\Data\Db\DbConnection;
use Icinga\Exception\ProgrammingError; use Icinga\Exception\ProgrammingError;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\Util; use Icinga\Module\Director\Util;
use Icinga\Module\Director\Objects\IcingaCommand; use Icinga\Module\Director\Objects\IcingaCommand;
use Icinga\Module\Director\Objects\IcingaHost; use Icinga\Module\Director\Objects\IcingaHost;
@ -32,7 +32,7 @@ class IcingaConfig
public static $table = 'director_generated_config'; public static $table = 'director_generated_config';
protected function __construct(DbConnection $connection) protected function __construct(Db $connection)
{ {
$this->connection = $connection; $this->connection = $connection;
$this->db = $connection->getDbAdapter(); $this->db = $connection->getDbAdapter();
@ -77,20 +77,20 @@ class IcingaConfig
return $files; return $files;
} }
public static function fromDb($checksum, DbConnection $connection) public static function load($checksum, Db $connection)
{ {
$config = new static($connection); $config = new static($connection);
$config->loadFromDb($checksum); $config->loadFromDb($checksum);
return $config; return $config;
} }
public static function generate(DbConnection $connection) public static function generate(Db $connection)
{ {
$config = new static($connection); $config = new static($connection);
return $config->storeIfModified(); return $config->storeIfModified();
} }
public static function wouldChange(DbConnection $connection) public static function wouldChange(Db $connection)
{ {
$config = new static($connection); $config = new static($connection);
return $config->hasBeenModified(); return $config->hasBeenModified();