mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 06:44:33 +02:00
Merge pull request #2951 from Icinga/bugfix/monitored-object-detailview-extension-style-2949
Style monitored objects' detailview extensions as expected
This commit is contained in:
commit
e276dfc517
@ -174,7 +174,7 @@ class ClassLoader
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function extractModuleName($class)
|
public static function extractModuleName($class)
|
||||||
{
|
{
|
||||||
return lcfirst(
|
return lcfirst(
|
||||||
substr(
|
substr(
|
||||||
@ -194,7 +194,7 @@ class ClassLoader
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function classBelongsToModule($class)
|
public static function classBelongsToModule($class)
|
||||||
{
|
{
|
||||||
return substr($class, 0, self::MODULE_PREFIX_LENGTH) === self::MODULE_PREFIX;
|
return substr($class, 0, self::MODULE_PREFIX_LENGTH) === self::MODULE_PREFIX;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Hook;
|
namespace Icinga\Module\Monitoring\Hook;
|
||||||
|
|
||||||
|
use Icinga\Application\ClassLoader;
|
||||||
|
use Icinga\Application\Icinga;
|
||||||
|
use Icinga\Application\Modules\Module;
|
||||||
use Icinga\Module\Monitoring\Object\MonitoredObject;
|
use Icinga\Module\Monitoring\Object\MonitoredObject;
|
||||||
use Icinga\Web\View;
|
use Icinga\Web\View;
|
||||||
|
|
||||||
@ -20,6 +23,13 @@ abstract class DetailviewExtensionHook
|
|||||||
*/
|
*/
|
||||||
private $view;
|
private $view;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The module of the derived class
|
||||||
|
*
|
||||||
|
* @var Module
|
||||||
|
*/
|
||||||
|
private $module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new hook
|
* Create a new hook
|
||||||
*
|
*
|
||||||
@ -68,4 +78,35 @@ abstract class DetailviewExtensionHook
|
|||||||
$this->view = $view;
|
$this->view = $view;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the module of the derived class
|
||||||
|
*
|
||||||
|
* @return Module
|
||||||
|
*/
|
||||||
|
public function getModule()
|
||||||
|
{
|
||||||
|
if ($this->module === null) {
|
||||||
|
$class = get_class($this);
|
||||||
|
if (ClassLoader::classBelongsToModule($class)) {
|
||||||
|
$this->module = Icinga::app()->getModuleManager()->getModule(ClassLoader::extractModuleName($class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->module;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the module of the derived class
|
||||||
|
*
|
||||||
|
* @param Module $module
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setModule(Module $module)
|
||||||
|
{
|
||||||
|
$this->module = $module;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,10 @@ abstract class MonitoredObjectController extends Controller
|
|||||||
$this->view->extensionsHtml = array();
|
$this->view->extensionsHtml = array();
|
||||||
foreach (Hook::all('Monitoring\DetailviewExtension') as $hook) {
|
foreach (Hook::all('Monitoring\DetailviewExtension') as $hook) {
|
||||||
/** @var DetailviewExtensionHook $hook */
|
/** @var DetailviewExtensionHook $hook */
|
||||||
$this->view->extensionsHtml[] = $hook->setView($this->view)->getHtmlForObject($this->object);
|
$this->view->extensionsHtml[] =
|
||||||
|
'<div class="icinga-module module-' . $this->view->escape($hook->getModule()->getName()) . '">'
|
||||||
|
. $hook->setView($this->view)->getHtmlForObject($this->object)
|
||||||
|
. '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user