summaryrefslogtreecommitdiffstats
path: root/library/Director/Web/Controller/ObjectsController.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Director/Web/Controller/ObjectsController.php')
-rw-r--r--library/Director/Web/Controller/ObjectsController.php28
1 files changed, 17 insertions, 11 deletions
diff --git a/library/Director/Web/Controller/ObjectsController.php b/library/Director/Web/Controller/ObjectsController.php
index 8c10b44..c4c96c5 100644
--- a/library/Director/Web/Controller/ObjectsController.php
+++ b/library/Director/Web/Controller/ObjectsController.php
@@ -13,6 +13,7 @@ use Icinga\Module\Director\Forms\IcingaMultiEditForm;
use Icinga\Module\Director\Objects\IcingaCommand;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Objects\IcingaObject;
+use Icinga\Module\Director\Objects\IcingaService;
use Icinga\Module\Director\RestApi\IcingaObjectsHandler;
use Icinga\Module\Director\Web\ActionBar\ObjectsActionBar;
use Icinga\Module\Director\Web\ActionBar\TemplateActionBar;
@@ -84,8 +85,9 @@ abstract class ObjectsController extends ActionController
} elseif ($request->getActionName() === 'applyrules') {
$table->filterObjectType('apply');
}
+ /** @var ?string $search */
$search = $this->params->get('q');
- if ($search !== null && \strlen($search) > 0) {
+ if ($search) {
$table->search($search);
}
@@ -110,7 +112,7 @@ abstract class ObjectsController extends ActionController
$type = $this->getType();
if ($this->params->get('format') === 'json') {
$filename = sprintf(
- "director-${type}_%s.json",
+ "director-{$type}_%s.json",
date('YmdHis')
);
$this->getResponse()->setHeader('Content-disposition', "attachment; filename=$filename", true);
@@ -124,7 +126,7 @@ abstract class ObjectsController extends ActionController
->addTitle($this->translate(ucfirst($this->getPluralType())))
->actions(new ObjectsActionBar($this->getBaseObjectUrl(), $this->url()));
- $this->content()->add(new BranchedObjectsHint($this->getBranch(), $this->Auth()));
+ $this->content()->add(new BranchedObjectsHint($this->getBranch(), $this->Auth(), $this->hasPreferredBranch()));
if ($type === 'command' && $this->params->get('type') === 'external_object') {
$this->tabs()->activate('external');
@@ -143,8 +145,7 @@ abstract class ObjectsController extends ActionController
*/
protected function getTable()
{
- $table = ObjectsTable::create($this->getType(), $this->db())
- ->setAuth($this->getAuth())
+ $table = ObjectsTable::create($this->getType(), $this->db(), $this->getAuth())
->setBranchUuid($this->getBranchUuid())
->setBaseObjectUrl($this->getBaseObjectUrl());
@@ -157,7 +158,7 @@ abstract class ObjectsController extends ActionController
*/
protected function getApplyRulesTable()
{
- $table = new ApplyRulesTable($this->db());
+ $table = (new ApplyRulesTable($this->db()))->setBranch($this->getBranch());
$table->setType($this->getType())
->setBaseObjectUrl($this->getBaseObjectUrl());
$this->eventuallyFilterCommand($table);
@@ -235,7 +236,7 @@ abstract class ObjectsController extends ActionController
if ($this->params->get('format') === 'json') {
$filename = sprintf(
- "director-${type}-templates_%s.json",
+ "director-{$type}-templates_%s.json",
date('YmdHis')
);
$this->getResponse()->setHeader('Content-disposition', "attachment; filename=$filename", true);
@@ -290,7 +291,7 @@ abstract class ObjectsController extends ActionController
if ($this->params->get('format') === 'json') {
$filename = sprintf(
- "director-${type}-applyrules_%s.json",
+ "director-{$type}-applyrules_%s.json",
date('YmdHis')
);
$this->getResponse()->setHeader('Content-disposition', "attachment; filename=$filename", true);
@@ -313,7 +314,7 @@ abstract class ObjectsController extends ActionController
->add(
Link::create(
$this->translate('Add'),
- "${baseUrl}/add",
+ "{$baseUrl}/add",
['type' => 'apply'],
[
'title' => sprintf(
@@ -354,7 +355,7 @@ abstract class ObjectsController extends ActionController
$this->actions()->add(
Link::create(
$this->translate('Add'),
- "director/${type}set/add",
+ "director/{$type}set/add",
null,
[
'title' => sprintf(
@@ -409,7 +410,12 @@ abstract class ObjectsController extends ActionController
$objects[$name] = $class::load($name, $db);
} elseif ($col === 'uuid') {
$object = $store->load($table, Uuid::fromString($ex->getExpression()));
- $objects[$object->getObjectName()] = $object;
+ if ($object instanceof IcingaService) {
+ $host = $object->getRelated('host');
+ $objects[$host->getObjectName() . ': ' . $object->getObjectName()] = $object;
+ } else {
+ $objects[$object->getObjectName()] = $object;
+ }
} else {
throw new InvalidArgumentException("'$col' is no a valid key component for '$type'");
}