mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2026-05-28 04:35:53 -04:00
DbUtil: helper for pgsql binary resource handling
This commit is contained in:
parent
ff57ec5c77
commit
257537d022
5 changed files with 25 additions and 7 deletions
|
|
@ -45,7 +45,7 @@ class Branch
|
|||
if (strlen($row->uuid) !== 16) {
|
||||
throw new RuntimeException('Valid UUID expected, got ' . var_export($row->uuid, 1));
|
||||
}
|
||||
$self->branchUuid = Uuid::fromBytes($row->uuid);
|
||||
$self->branchUuid = Uuid::fromBytes(Db\DbUtil::binaryResult($row->uuid));
|
||||
$self->name = $row->branch_name;
|
||||
$self->owner = $row->owner;
|
||||
$self->tsMergeRequest = $row->ts_merge_request;
|
||||
|
|
|
|||
18
library/Director/Db/DbUtil.php
Normal file
18
library/Director/Db/DbUtil.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Db;
|
||||
|
||||
use function is_resource;
|
||||
use function stream_get_contents;
|
||||
|
||||
class DbUtil
|
||||
{
|
||||
public static function binaryResult($value)
|
||||
{
|
||||
if (is_resource($value)) {
|
||||
return stream_get_contents($value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ use Icinga\Authentication\Auth;
|
|||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Module\Director\Db;
|
||||
use Icinga\Module\Director\Db\DbUtil;
|
||||
use Icinga\Module\Director\Db\IcingaObjectFilterHelper;
|
||||
use Icinga\Module\Director\IcingaConfig\AssignRenderer;
|
||||
use Icinga\Module\Director\Objects\IcingaObject;
|
||||
|
|
@ -73,9 +74,7 @@ class ApplyRulesTable extends ZfQueryBasedTable
|
|||
|
||||
public function renderRow($row)
|
||||
{
|
||||
if (isset($row->uuid) && is_resource($row->uuid)) {
|
||||
$row->uuid = stream_get_contents($row->uuid);
|
||||
}
|
||||
$row->uuid = DbUtil::binaryResult($row->uuid);
|
||||
if ($this->linkWithName) {
|
||||
$params = ['name' => $row->object_name];
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class ObjectSetTable extends ZfQueryBasedTable
|
|||
$params['id'] = $row->id;
|
||||
} else {
|
||||
$params = [
|
||||
'uuid' => Uuid::fromBytes($row->uuid)->toString(),
|
||||
'uuid' => Uuid::fromBytes(Db\DbUtil::binaryResult($row->uuid))->toString(),
|
||||
'name' => $row->object_name
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Icinga\Module\Director\Web\Table;
|
||||
|
||||
use Icinga\Module\Director\Db\DbUtil;
|
||||
use ipl\Html\Html;
|
||||
use gipfl\IcingaWeb2\Table\Extension\MultiSelect;
|
||||
use gipfl\IcingaWeb2\Link;
|
||||
|
|
@ -50,7 +51,7 @@ class ObjectsTableService extends ObjectsTable
|
|||
public function renderRow($row)
|
||||
{
|
||||
$params = [
|
||||
'uuid' => Uuid::fromBytes($row->uuid)->toString(),
|
||||
'uuid' => Uuid::fromBytes(DbUtil::binaryResult($row->uuid))->toString(),
|
||||
];
|
||||
if ($row->host !== null) {
|
||||
$params['host'] = $row->host;
|
||||
|
|
@ -59,7 +60,7 @@ class ObjectsTableService extends ObjectsTable
|
|||
/*
|
||||
if ($this->branchUuid) {
|
||||
$url = Url::fromPath('director/service/edit', [
|
||||
'uuid' => Uuid::fromBytes($row->uuid)->toString(),
|
||||
'uuid' => Uuid::fromBytes(DbUtil::binaryResult($row->uuid))->toString(),
|
||||
'host' => $row->host,
|
||||
]);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue