Skip to content

Commit

Permalink
Implement Icinga Dependency Configuration
Browse files Browse the repository at this point in the history
refs #11332
  • Loading branch information
mdetrano authored and Thomas-Gelf committed Dec 29, 2016
1 parent 37bdbe2 commit cb6f04c
Show file tree
Hide file tree
Showing 11 changed files with 597 additions and 33 deletions.
15 changes: 15 additions & 0 deletions application/clicommands/DependencyCommand.php
@@ -0,0 +1,15 @@
<?php

namespace Icinga\Module\Director\Clicommands;

use Icinga\Module\Director\Cli\ObjectCommand;

/**
* Manage Icinga Dependencies
*
* Use this command to show, create, modify or delete Icinga Dependency
* objects
*/
class DependencyCommand extends ObjectCommand
{
}
9 changes: 9 additions & 0 deletions application/controllers/DependenciesController.php
@@ -0,0 +1,9 @@
<?php

namespace Icinga\Module\Director\Controllers;

use Icinga\Module\Director\Web\Controller\ObjectsController;

class DependenciesController extends ObjectsController
{
}
72 changes: 72 additions & 0 deletions application/controllers/DependencyController.php
@@ -0,0 +1,72 @@
<?php

namespace Icinga\Module\Director\Controllers;

use Icinga\Module\Director\Web\Controller\ObjectController;
use Icinga\Module\Director\Objects\IcingaDependency;

class DependencyController extends ObjectController
{
protected $apply;

protected function beforeTabs()
{
}

public function init()
{
parent::init();

if ($apply = $this->params->get('apply')) {
$this->apply = IcingaDependency::load(
array('object_name' => $apply, 'object_type' => 'template'),
$this->db()
);
}

}

protected function loadObject()
{
if ($this->object === null) {
if ($name = $this->params->get('name')) {
$params = array('object_name' => $name);
$db = $this->db();

$this->object = IcingaDependency::load($params, $db);
} else {
parent::loadObject();
}
}

return $this->object;
}

public function addAction()
{
parent::addAction();

if ($this->apply) {
$this->view->title = sprintf(
$this->translate('Apply "%s"'),
$this->apply->object_name
);
}
}

public function loadForm($name)
{
$form = parent::loadForm($name);
return $form;
}

protected function beforeHandlingAddRequest($form)
{
if ($this->apply) {
$form->createApplyRuleFor($this->apply);
}
}



}

0 comments on commit cb6f04c

Please sign in to comment.