library: php8-related cleanup

This commit is contained in:
Thomas Gelf 2021-12-06 23:03:06 +01:00
parent 2f326576d9
commit 100bc4b777
9 changed files with 34 additions and 18 deletions

View File

@ -546,7 +546,7 @@ class SyncruleController extends ActionController
$run = SyncRun::load($runId, $this->db());
$this->content()->add(new SyncRunDetails($run));
}
SyncRunTable::create($rule)->renderTo($this);
(new SyncRunTable($rule))->renderTo($this);
}
/**

View File

@ -29,7 +29,7 @@ class IcingaScheduledDowntimeRange extends DbObject
return false;
}
if ((int) strftime('%w', $now) !== $weekDay) {
if ((int) date('w', $now) !== $weekDay) {
return false;
}

View File

@ -29,7 +29,7 @@ class IcingaTimePeriodRange extends DbObject
return false;
}
if ((int) strftime('%w', $now) !== $weekDay) {
if ((int) date('w', $now) !== $weekDay) {
return false;
}

View File

@ -172,7 +172,7 @@ abstract class ObjectApplyMatches
$col = $filter->getColumn();
$type = static::$type;
if (substr($col, 0, strlen($type) + 1) === "${type}.") {
if ($type && substr($col, 0, strlen($type) + 1) === "${type}.") {
$filter->setColumn($col = substr($col, strlen($type) + 1));
}

View File

@ -329,7 +329,7 @@ class IcingaObjectFieldLoader
if (array_key_exists($col, $elements)) {
$el = $elements[$col];
$existingClass = $el->getAttrib('class');
if (strlen($existingClass)) {
if ($existingClass !== null && strlen($existingClass)) {
$el->setAttrib('class', $existingClass . ' autosubmit');
} else {
$el->setAttrib('class', 'autosubmit');

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Web\Table;
use gipfl\Format\LocalTimeFormat;
use Icinga\Module\Director\Util;
use ipl\Html\BaseHtmlElement;
use gipfl\IcingaWeb2\Link;
@ -32,6 +33,15 @@ class ActivityLogTable extends ZfQueryBasedTable
'action',
);
/** @var LocalTimeFormat */
protected $timeFormat;
public function __construct($db)
{
parent::__construct($db);
$this->timeFormat = new LocalTimeFormat();
}
public function assemble()
{
$this->getAttributes()->add('class', 'activity-log');
@ -55,7 +65,7 @@ class ActivityLogTable extends ZfQueryBasedTable
return $this::tr([
$this::td($this->makeLink($row))->setSeparator(' '),
$this::td(date('H:i:s', $row->ts_change_time))
$this::td($this->timeFormat->getTime($row->ts_change_time))
])->addAttributes(['class' => $action]);
}

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Web\Table;
use gipfl\Format\LocalTimeFormat;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\Db\Branch\BranchActivity;
use Icinga\Module\Director\Util;
@ -19,10 +20,14 @@ class BranchActivityTable extends ZfQueryBasedTable
/** @var ?UuidInterface */
protected $objectUuid;
/** @var LocalTimeFormat */
protected $timeFormat;
public function __construct(UuidInterface $branchUuid, $db, UuidInterface $objectUuid = null)
{
$this->branchUuid = $branchUuid;
$this->objectUuid = $objectUuid;
$this->timeFormat = new LocalTimeFormat();
parent::__construct($db);
}
@ -38,7 +43,7 @@ class BranchActivityTable extends ZfQueryBasedTable
$activity = BranchActivity::fromDbRow($row);
return $this::tr([
$this::td($this->makeBranchLink($activity))->setSeparator(' '),
$this::td(strftime('%H:%M:%S', $ts))
$this::td($this->timeFormat->getTime($ts))
])->addAttributes(['class' => ['action-' . $activity->getAction(), 'branched']]);
}

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Web\Table;
use gipfl\Format\LocalTimeFormat;
use Icinga\Module\Director\Objects\SyncRule;
use gipfl\IcingaWeb2\Link;
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
@ -11,14 +12,16 @@ class SyncRunTable extends ZfQueryBasedTable
/** @var SyncRule */
protected $rule;
public static function create(SyncRule $rule)
protected $timeFormat;
public function __construct(SyncRule $rule)
{
$table = new static($rule->getConnection());
$table->getAttributes()
parent::__construct($rule->getConnection());
$this->timeFormat = new LocalTimeFormat();
$this->getAttributes()
->set('data-base-target', '_self')
->add('class', 'history');
$table->rule = $rule;
return $table;
$this->rule = $rule;
}
public function renderRow($row)
@ -28,7 +31,7 @@ class SyncRunTable extends ZfQueryBasedTable
return $this::tr([
$this::td($this->makeSummary($row)),
$this::td(new Link(
strftime('%H:%M:%S', $time),
$this->timeFormat->getTime($time),
'director/syncrule/history',
[
'id' => $row->rule_id,

View File

@ -2,8 +2,7 @@
namespace Icinga\Module\Director\Web\Widget;
use gipfl\Diff\HtmlRenderer\SideBySideDiff;
use gipfl\Diff\PhpDiff;
use gipfl\Json\JsonString;
use ipl\Html\HtmlDocument;
use ipl\Html\HtmlElement;
use Icinga\Date\DateFormatter;
@ -21,7 +20,6 @@ use gipfl\Translation\TranslationHelper;
use gipfl\IcingaWeb2\Url;
use gipfl\IcingaWeb2\Widget\NameValueTable;
use gipfl\IcingaWeb2\Widget\Tabs;
use ipl\Html\ValidHtml;
class ActivityLogInfo extends HtmlDocument
{
@ -223,7 +221,7 @@ class ActivityLogInfo extends HtmlDocument
{
if ($this->oldProperties === null) {
if (property_exists($this->entry, 'old_properties')) {
$this->oldProperties = json_decode($this->entry->old_properties);
$this->oldProperties = JsonString::decodeOptional($this->entry->old_properties);
}
if ($this->oldProperties === null) {
$this->oldProperties = new \stdClass;
@ -237,7 +235,7 @@ class ActivityLogInfo extends HtmlDocument
{
if ($this->newProperties === null) {
if (property_exists($this->entry, 'new_properties')) {
$this->newProperties = json_decode($this->entry->new_properties);
$this->newProperties = JsonString::decodeOptional($this->entry->new_properties);
}
if ($this->newProperties === null) {
$this->newProperties = new \stdClass;