mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-01-30 07:09:26 -05:00
Define variable type when method returns a class object
- This helps the IDE to find class methods and resolves the `call to an undefined method` issue
This commit is contained in:
parent
21933d1868
commit
6306b5306c
11 changed files with 46 additions and 15 deletions
|
|
@ -132,8 +132,8 @@ class ProcessCommand extends Command
|
|||
}
|
||||
}
|
||||
|
||||
/** @var BpNode $node */
|
||||
try {
|
||||
/** @var BpNode $node */
|
||||
$node = $bp->getNode($nodeName);
|
||||
if (Module::exists('icingadb')
|
||||
&& (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Icinga\Module\Businessprocess\IcingaDbObject;
|
|||
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
|
||||
use Icinga\Module\Icingadb\Model\Host;
|
||||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Module\Monitoring\DataView\DataView;
|
||||
use Icinga\Web\Url;
|
||||
use ipl\Stdlib\Filter;
|
||||
|
||||
|
|
@ -54,7 +55,9 @@ class HostController extends Controller
|
|||
->from('hoststatus', array('host_name'))
|
||||
->where('host_name', $hostName);
|
||||
|
||||
if ($this->applyRestriction('monitoring/filter/objects', $query)->fetchRow() !== false) {
|
||||
/** @var DataView $restrictedQuery */
|
||||
$restrictedQuery = $this->applyRestriction('monitoring/filter/objects', $query);
|
||||
if ($restrictedQuery->fetchRow() !== false) {
|
||||
$this->redirectNow(Url::fromPath('monitoring/host/show')->setParams($this->params));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ use ipl\Html\HtmlString;
|
|||
use ipl\Html\TemplateString;
|
||||
use ipl\Html\Text;
|
||||
use ipl\Web\Control\SortControl;
|
||||
use ipl\Web\FormElement\TermInput;
|
||||
use ipl\Web\Widget\Link;
|
||||
use ipl\Web\Widget\Icon;
|
||||
|
||||
|
|
@ -282,7 +283,9 @@ class ProcessController extends Controller
|
|||
->handleRequest($this->getServerRequest());
|
||||
|
||||
if ($form->hasElement('children')) {
|
||||
foreach ($form->getElement('children')->prepareMultipartUpdate($this->getServerRequest()) as $update) {
|
||||
/** @var TermInput $childrenElement */
|
||||
$childrenElement = $form->getElement('children');
|
||||
foreach ($childrenElement->prepareMultipartUpdate($this->getServerRequest()) as $update) {
|
||||
if (! is_array($update)) {
|
||||
$update = [$update];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Icinga\Module\Businessprocess\IcingaDbObject;
|
|||
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
|
||||
use Icinga\Module\Icingadb\Model\Service;
|
||||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Module\Monitoring\DataView\DataView;
|
||||
use Icinga\Web\Url;
|
||||
use ipl\Stdlib\Filter;
|
||||
|
||||
|
|
@ -61,7 +62,9 @@ class ServiceController extends Controller
|
|||
->where('host_name', $hostName)
|
||||
->where('service_description', $serviceName);
|
||||
|
||||
if ($this->applyRestriction('monitoring/filter/objects', $query)->fetchRow() !== false) {
|
||||
/** @var DataView $restrictedQuery */
|
||||
$restrictedQuery = $this->applyRestriction('monitoring/filter/objects', $query);
|
||||
if ($restrictedQuery->fetchRow() !== false) {
|
||||
$this->redirectNow(Url::fromPath('monitoring/service/show')->setParams($this->params));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ class BpUploadForm extends BpConfigBaseForm
|
|||
|
||||
protected function processUploadedSource()
|
||||
{
|
||||
/** @var \Zend_Form_Element_File $el */
|
||||
/** @var ?\Zend_Form_Element_File $el */
|
||||
$el = $this->getElement('uploaded_file');
|
||||
|
||||
if ($el && $this->hasBeenSent()) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use Icinga\Module\Businessprocess\BpNode;
|
|||
use Icinga\Module\Businessprocess\Modification\ProcessChanges;
|
||||
use Icinga\Module\Businessprocess\Node;
|
||||
use Icinga\Module\Businessprocess\Web\Form\BpConfigBaseForm;
|
||||
use Icinga\Web\View;
|
||||
|
||||
class DeleteNodeForm extends BpConfigBaseForm
|
||||
{
|
||||
|
|
@ -19,6 +20,8 @@ class DeleteNodeForm extends BpConfigBaseForm
|
|||
{
|
||||
$node = $this->node;
|
||||
$nodeName = $node->getAlias() ?? $node->getName();
|
||||
|
||||
/** @var View $view */
|
||||
$view = $this->getView();
|
||||
$this->addHtml(
|
||||
'<h2>' . $view->escape(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Businessprocess\Forms;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Web;
|
||||
use Icinga\Exception\Http\HttpException;
|
||||
use Icinga\Module\Businessprocess\BpConfig;
|
||||
use Icinga\Module\Businessprocess\BpNode;
|
||||
|
|
@ -136,7 +137,9 @@ class MoveNodeForm extends BpConfigBaseForm
|
|||
);
|
||||
} catch (ModificationError $e) {
|
||||
$this->notifyError($e->getMessage());
|
||||
Icinga::app()->getResponse()
|
||||
/** @var Web $app */
|
||||
$app = Icinga::app();
|
||||
$app->getResponse()
|
||||
// Web 2's JS forces a content update for non-200s. Our own JS
|
||||
// can't prevent this, hence we're not making this a 400 :(
|
||||
//->setHttpResponseCode(400)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Icinga\Module\Businessprocess\Modification\ProcessChanges;
|
|||
use Icinga\Module\Businessprocess\Node;
|
||||
use Icinga\Module\Businessprocess\Web\Form\BpConfigBaseForm;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Web\View;
|
||||
|
||||
class ProcessForm extends BpConfigBaseForm
|
||||
{
|
||||
|
|
@ -16,8 +17,11 @@ class ProcessForm extends BpConfigBaseForm
|
|||
public function setup()
|
||||
{
|
||||
if ($this->node !== null) {
|
||||
/** @var View $view */
|
||||
$view = $this->getView();
|
||||
|
||||
$this->addHtml(
|
||||
'<h2>' . $this->getView()->escape(
|
||||
'<h2>' . $view->escape(
|
||||
sprintf($this->translate('Modify "%s"'), $this->node->getAlias())
|
||||
) . '</h2>'
|
||||
);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace Icinga\Module\Businessprocess\Forms;
|
|||
use Icinga\Module\Businessprocess\MonitoredNode;
|
||||
use Icinga\Module\Businessprocess\Simulation;
|
||||
use Icinga\Module\Businessprocess\Web\Form\BpConfigBaseForm;
|
||||
use Icinga\Web\View;
|
||||
|
||||
class SimulationForm extends BpConfigBaseForm
|
||||
{
|
||||
|
|
@ -36,6 +37,7 @@ class SimulationForm extends BpConfigBaseForm
|
|||
$node = $this->node;
|
||||
}
|
||||
|
||||
/** @var View $view */
|
||||
$view = $this->getView();
|
||||
if ($hasSimulation) {
|
||||
$title = $this->translate('Modify simulation for %s');
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Businessprocess\Web\Form;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Web;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Web\Request;
|
||||
|
|
@ -428,14 +429,18 @@ abstract class QuickForm extends QuickBaseForm
|
|||
|
||||
protected function redirectAndExit($url)
|
||||
{
|
||||
/** @var Web $app */
|
||||
$app = Icinga::app();
|
||||
/** @var Response $response */
|
||||
$response = Icinga::app()->getFrontController()->getResponse();
|
||||
$response = $app->getFrontController()->getResponse();
|
||||
$response->redirectAndExit($url);
|
||||
}
|
||||
|
||||
protected function setHttpResponseCode($code)
|
||||
{
|
||||
Icinga::app()->getFrontController()->getResponse()->setHttpResponseCode($code);
|
||||
/** @var Web $app */
|
||||
$app = Icinga::app();
|
||||
$app->getFrontController()->getResponse()->setHttpResponseCode($code);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -461,8 +466,10 @@ abstract class QuickForm extends QuickBaseForm
|
|||
public function getRequest()
|
||||
{
|
||||
if ($this->request === null) {
|
||||
/** @var Web $app */
|
||||
$app = Icinga::app();
|
||||
/** @var Request $request */
|
||||
$request = Icinga::app()->getFrontController()->getRequest();
|
||||
$request = $app->getFrontController()->getRequest();
|
||||
$this->setRequest($request);
|
||||
}
|
||||
return $this->request;
|
||||
|
|
@ -471,14 +478,15 @@ abstract class QuickForm extends QuickBaseForm
|
|||
public function hasBeenSent()
|
||||
{
|
||||
if ($this->hasBeenSent === null) {
|
||||
|
||||
/** @var Request $req */
|
||||
if ($this->request === null) {
|
||||
$req = Icinga::app()->getFrontController()->getRequest();
|
||||
/** @var Web $app */
|
||||
$app = Icinga::app();
|
||||
$req = $app->getFrontController()->getRequest();
|
||||
} else {
|
||||
$req = $this->request;
|
||||
}
|
||||
|
||||
/** @var Request $req */
|
||||
if ($req->isPost()) {
|
||||
$post = $req->getPost();
|
||||
$this->hasBeenSent = array_key_exists(self::ID, $post) &&
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Businessprocess\Web;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Web;
|
||||
use Icinga\Web\Url as WebUrl;
|
||||
|
||||
/**
|
||||
|
|
@ -19,8 +20,9 @@ class Url extends WebUrl
|
|||
$app = Icinga::app();
|
||||
if ($app->isCli()) {
|
||||
return new FakeRequest();
|
||||
} else {
|
||||
return $app->getRequest();
|
||||
}
|
||||
|
||||
/** @var Web $app */
|
||||
return $app->getRequest();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue