mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 16:54:06 +02:00
BranchSupport: new helper class
This commit is contained in:
parent
b2afca2496
commit
956708475e
38
library/Director/Db/Branch/BranchSupport.php
Normal file
38
library/Director/Db/Branch/BranchSupport.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Db\Branch;
|
||||
|
||||
use Icinga\Module\Director\Data\Db\DbObjectTypeRegistry;
|
||||
use Icinga\Module\Director\Objects\SyncRule;
|
||||
|
||||
class BranchSupport
|
||||
{
|
||||
const BRANCHED_TABLES = [
|
||||
'icinga_apiuser',
|
||||
'icinga_command',
|
||||
'icinga_dependency',
|
||||
'icinga_endpoint',
|
||||
'icinga_host',
|
||||
'icinga_hostgroup',
|
||||
'icinga_notification',
|
||||
'icinga_scheduled_downtime',
|
||||
'icinga_service',
|
||||
'icinga_servicegroup',
|
||||
'icinga_timeperiod',
|
||||
'icinga_user',
|
||||
'icinga_usergroup',
|
||||
'icinga_zone',
|
||||
];
|
||||
|
||||
public static function existsForTableName($table)
|
||||
{
|
||||
return in_array($table, self::BRANCHED_TABLES, true);
|
||||
}
|
||||
|
||||
public static function existsForSyncRule(SyncRule $rule)
|
||||
{
|
||||
return static::existsForTableName(
|
||||
DbObjectTypeRegistry::tableNameByType($rule->get('object_type'))
|
||||
);
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ use Icinga\Module\Director\Data\Db\DbObjectStore;
|
||||
use Icinga\Module\Director\Data\Db\DbObjectTypeRegistry;
|
||||
use Icinga\Module\Director\Db\Branch\Branch;
|
||||
use Icinga\Module\Director\Db\Branch\BranchStore;
|
||||
use Icinga\Module\Director\Db\Branch\BranchSupport;
|
||||
use Icinga\Module\Director\Objects\IcingaObject;
|
||||
use Icinga\Module\Director\Web\Widget\NotInBranchedHint;
|
||||
|
||||
@ -17,23 +18,6 @@ trait BranchHelper
|
||||
/** @var BranchStore */
|
||||
protected $branchStore;
|
||||
|
||||
protected static $banchedTables = [
|
||||
'icinga_apiuser',
|
||||
'icinga_command',
|
||||
'icinga_dependency',
|
||||
'icinga_endpoint',
|
||||
'icinga_host',
|
||||
'icinga_hostgroup',
|
||||
'icinga_notification',
|
||||
'icinga_scheduled_downtime',
|
||||
'icinga_service',
|
||||
'icinga_servicegroup',
|
||||
'icinga_timeperiod',
|
||||
'icinga_user',
|
||||
'icinga_usergroup',
|
||||
'icinga_zone',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return false|\Ramsey\Uuid\UuidInterface
|
||||
*/
|
||||
@ -69,14 +53,9 @@ trait BranchHelper
|
||||
return $this->getBranchUuid() !== null;
|
||||
}
|
||||
|
||||
protected function tableHasBranchSupport($table)
|
||||
{
|
||||
return in_array($table, self::$banchedTables, true);
|
||||
}
|
||||
|
||||
protected function enableStaticObjectLoader($table)
|
||||
{
|
||||
if ($this->tableHasBranchSupport($table)) {
|
||||
if (BranchSupport::existsForTableName($table)) {
|
||||
IcingaObject::setDbObjectStore(new DbObjectStore($this->db(), $this->getBranch()));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user