Use $isIcingadbPreferred to check if the businessproces preders icingadb as default backend.

This commit is contained in:
raviks789 2022-02-15 10:24:58 +01:00
parent 605834e7c4
commit daf0384e66
2 changed files with 21 additions and 18 deletions

View file

@ -12,24 +12,27 @@ use ipl\Stdlib\Filter;
class HostController extends Controller
{
protected $isIcingadb;
protected $explicitIcingadb;
/**
* True if business process prefers to use icingadb as backend for it's nodes
*
* @var bool
*/
protected $isIcingadbPreferred;
protected function moduleInit()
{
$this->isIcingadb = $this->params->shift('backend') === '_icingadb';
$this->explicitIcingadb = Module::exists('icingadb')
$this->isIcingadbPreferred = Module::exists('icingadb')
&& ! $this->params->has('backend')
&& IcingadbSupport::useIcingaDbAsBackend();
if (! $this->isIcingadb) {
if (! $this->isIcingadbPreferred) {
parent::moduleInit();
}
}
public function showAction()
{
if ($this->isIcingadb || $this->explicitIcingadb) {
if ($this->isIcingadbPreferred) {
$hostName = $this->params->shift('host');
$query = Host::on(IcingaDbObject::fetchDb());

View file

@ -2,7 +2,6 @@
namespace Icinga\Module\Businessprocess\Controllers;
use Dompdf\Exception;
use Icinga\Application\Modules\Module;
use Icinga\Module\Businessprocess\IcingaDbObject;
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
@ -13,30 +12,31 @@ use ipl\Stdlib\Filter;
class ServiceController extends Controller
{
protected $isIcingadb;
protected $explicitIcingadb;
/**
* True if business process prefers to use icingadb as backend for it's nodes
*
* @var bool
*/
protected $isIcingadbPreferred;
protected function moduleInit()
{
$this->isIcingadb = $this->params->shift('backend') === '_icingadb';
$this->explicitIcingadb = Module::exists('icingadb')
$this->isIcingadbPreferred = Module::exists('icingadb')
&& ! $this->params->has('backend')
&& IcingadbSupport::useIcingaDbAsBackend();
if (! $this->isIcingadb) {
if (! $this->isIcingadbPreferred) {
parent::moduleInit();
}
}
public function showAction()
{
$icingadb = $this->params->shift('icingadb');
if ($icingadb && Module::exists('icingadb')) {
if ($this->isIcingadbPreferred) {
$hostName = $this->params->shift('host');
$serviceName = $this->params->shift('service');
$query = Service::on(IcingaDbObject::fetchDb())->with('host');
$query = Service::on(IcingaDbObject::fetchDb());
IcingaDbObject::applyIcingaDbRestrictions($query);
$query->filter(Filter::all(