mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-27 17:49:35 -05:00
Cleanup, Url handling improvements, some helpers
This commit is contained in:
parent
1f61d8b728
commit
a00fdab37f
8 changed files with 68 additions and 9 deletions
|
|
@ -63,7 +63,7 @@ class BpNode extends Node
|
|||
$this->getState();
|
||||
$this->counters = self::$emptyStateSummary;
|
||||
|
||||
foreach ($this->children as $child) {
|
||||
foreach ($this->getChildren() as $child) {
|
||||
if ($child instanceof BpNode) {
|
||||
$counters = $child->getStateSummary();
|
||||
foreach ($counters as $k => $v) {
|
||||
|
|
|
|||
|
|
@ -425,6 +425,9 @@ class BusinessProcess
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BpNode[]
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->getRootNodes();
|
||||
|
|
|
|||
|
|
@ -5,22 +5,33 @@ namespace Icinga\Module\Businessprocess;
|
|||
use Icinga\Application\Icinga;
|
||||
use Icinga\Module\Businessprocess\Modification\ProcessChanges;
|
||||
use Icinga\Module\Businessprocess\Storage\LegacyStorage;
|
||||
use Icinga\Module\Businessprocess\Storage\Storage;
|
||||
use Icinga\Module\Businessprocess\Web\Component\ActionBar;
|
||||
use Icinga\Module\Businessprocess\Web\Form\FormLoader;
|
||||
use Icinga\Module\Businessprocess\Web\Url;
|
||||
use Icinga\Web\Controller as ModuleController;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Web\View;
|
||||
use Icinga\Web\Widget;
|
||||
|
||||
class Controller extends ModuleController
|
||||
{
|
||||
protected $config;
|
||||
|
||||
/** @deprecated, obsolete */
|
||||
protected $backend;
|
||||
|
||||
/** @var BusinessProcess */
|
||||
protected $bp;
|
||||
|
||||
/** @var View */
|
||||
public $view;
|
||||
|
||||
/** @var Storage */
|
||||
private $storage;
|
||||
|
||||
/** @var bool */
|
||||
private $showFullscreen;
|
||||
|
||||
/** @var Url */
|
||||
private $url;
|
||||
|
||||
public function init()
|
||||
|
|
@ -31,17 +42,31 @@ class Controller extends ModuleController
|
|||
}
|
||||
$this->view->errors = array();
|
||||
|
||||
$this->url();
|
||||
$this->view->showFullscreen
|
||||
= $this->showFullscreen
|
||||
= (bool) $this->_helper->layout()->showFullscreen;
|
||||
|
||||
$this->view->compact = $this->params->get('view') === 'compact';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Url
|
||||
*/
|
||||
protected function url()
|
||||
{
|
||||
if ($this->url === null) {
|
||||
$this->url = clone $this->getRequest()->getUrl();
|
||||
$this->url = Url::fromPath(
|
||||
$this->getRequest()->getUrl()->getPath()
|
||||
)->setParams($this->params);
|
||||
}
|
||||
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActionBar
|
||||
*/
|
||||
protected function actions()
|
||||
{
|
||||
if ($this->view->actions === null) {
|
||||
|
|
@ -64,6 +89,12 @@ class Controller extends ModuleController
|
|||
return $this->Window()->getSessionNamespace('businessprocess');
|
||||
}
|
||||
|
||||
protected function setViewScript($name)
|
||||
{
|
||||
$this->_helper->viewRenderer->setNoController(true);
|
||||
$this->_helper->viewRenderer->setScriptAction($name);
|
||||
}
|
||||
|
||||
protected function setTitle($title)
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
|
|
|||
|
|
@ -298,6 +298,11 @@ abstract class Node
|
|||
return count($this->parents) > 0;
|
||||
}
|
||||
|
||||
public function getParents()
|
||||
{
|
||||
return $this->parents;
|
||||
}
|
||||
|
||||
protected function stateToSortState($state)
|
||||
{
|
||||
if (array_key_exists($state, static::$stateToSortStateMap)) {
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
namespace Icinga\Module\Businessprocess;
|
||||
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Web\Session\SessionNamespace;
|
||||
|
||||
class Simulation
|
||||
{
|
||||
/**
|
||||
* @var Session
|
||||
* @var SessionNamespace
|
||||
*/
|
||||
protected $session;
|
||||
|
||||
|
|
@ -21,6 +22,9 @@ class Simulation
|
|||
*/
|
||||
protected $key;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $simulations;
|
||||
|
||||
public function __construct(BusinessProcess $bp, SessionNamespace $session)
|
||||
|
|
|
|||
|
|
@ -196,6 +196,8 @@ class LegacyStorage extends Storage
|
|||
|
||||
/**
|
||||
* @param BusinessProcess $process
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function storeProcess(BusinessProcess $process)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ class FakeRequest extends Request
|
|||
return self::$baseUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,18 @@ namespace Icinga\Module\Businessprocess\Web;
|
|||
use Icinga\Application\Icinga;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Web\Url as WebUrl;
|
||||
use Icinga\Web\UrlParams;
|
||||
|
||||
/**
|
||||
* Class Url
|
||||
*
|
||||
* The main purpose of this class is to get unit tests running on CLI
|
||||
* Little code from Icinga\Web\Url has been duplicated, as neither fromPath()
|
||||
* nor getRequest() can be extended in a meaningful way at the time of this
|
||||
* writing
|
||||
*
|
||||
* @package Icinga\Module\Businessprocess\Web
|
||||
*/
|
||||
class Url extends WebUrl
|
||||
{
|
||||
public static function fromPath($url, array $params = array(), $request = null)
|
||||
|
|
@ -33,7 +44,11 @@ class Url extends WebUrl
|
|||
if (isset($parts['path'])) {
|
||||
$self->setPath($parts['path']);
|
||||
}
|
||||
|
||||
|
||||
if (isset($urlParts['query'])) {
|
||||
$params = UrlParams::fromQueryString($urlParts['query'])->mergeValues($params);
|
||||
}
|
||||
|
||||
if (isset($parts['fragment'])) {
|
||||
$self->setAnchor($parts['fragment']);
|
||||
}
|
||||
|
|
@ -51,5 +66,4 @@ class Url extends WebUrl
|
|||
return $app->getRequest();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue