parent
0a9aa20dfa
commit
fb2abf40f8
|
@ -4,6 +4,7 @@
|
|||
namespace Icinga\Module\Monitoring\Hook;
|
||||
|
||||
use Icinga\Module\Monitoring\Object\MonitoredObject;
|
||||
use Icinga\Web\View;
|
||||
|
||||
/**
|
||||
* Base class for hooks extending the detail view of monitored objects
|
||||
|
@ -12,6 +13,13 @@ use Icinga\Module\Monitoring\Object\MonitoredObject;
|
|||
*/
|
||||
abstract class DetailviewExtensionHook
|
||||
{
|
||||
/**
|
||||
* The view the generated HTML will be included in
|
||||
*
|
||||
* @var View
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* Create a new hook
|
||||
*
|
||||
|
@ -37,4 +45,27 @@ abstract class DetailviewExtensionHook
|
|||
* @return string
|
||||
*/
|
||||
abstract public function getHtmlForObject(MonitoredObject $object);
|
||||
|
||||
/**
|
||||
* Get {@link view}
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function getView()
|
||||
{
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set {@link view}
|
||||
*
|
||||
* @param View $view
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setView($view)
|
||||
{
|
||||
$this->view = $view;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ abstract class MonitoredObjectController extends Controller
|
|||
$this->view->extensionsHtml = array();
|
||||
foreach (Hook::all('Monitoring\DetailviewExtension') as $hook) {
|
||||
/** @var DetailviewExtensionHook $hook */
|
||||
$this->view->extensionsHtml[] = $hook->getHtmlForObject($this->object);
|
||||
$this->view->extensionsHtml[] = $hook->setView($this->view)->getHtmlForObject($this->object);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue