icingaweb2/library/Icinga/Web/Hook/GrapherHook.php

113 lines
2.4 KiB
PHP
Raw Normal View History

<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Web\Hook;
use Icinga\Exception\ProgrammingError;
2014-09-04 13:31:04 +02:00
use Icinga\Module\Monitoring\Object\MonitoredObject;
/**
* Icinga Web Grapher Hook base class
*
* Extend this class if you want to integrate your graphing solution nicely into
2014-09-04 13:31:04 +02:00
* Icinga Web.
*/
2014-09-04 13:31:04 +02:00
abstract class GrapherHook extends WebBaseHook
{
/**
2014-09-04 13:31:04 +02:00
* Whether this grapher provides previews
*
* @var bool
*/
protected $hasPreviews = false;
2014-09-04 13:31:04 +02:00
/**
* Whether this grapher provides tiny previews
*
* @var bool
*/
protected $hasTinyPreviews = false;
/**
* Constructor must live without arguments right now
*
* Therefore the constructor is final, we might change our opinion about
* this one far day
*/
final public function __construct()
{
$this->init();
}
/**
* Overwrite this function if you want to do some initialization stuff
*
* @return void
*/
protected function init()
{
}
/**
2014-09-04 13:31:04 +02:00
* Whether this grapher provides previews
*
* @return bool
*/
2014-09-04 13:31:04 +02:00
public function hasPreviews()
{
2014-09-04 13:31:04 +02:00
return $this->hasPreviews;
}
/**
2014-09-04 13:31:04 +02:00
* Whether this grapher provides tiny previews
*
2014-09-04 13:31:04 +02:00
* @return bool
*/
2014-09-04 13:31:04 +02:00
public function hasTinyPreviews()
{
2014-09-04 13:31:04 +02:00
return $this->hasTinyPreviews;
}
/**
2014-09-04 13:31:04 +02:00
* Whether a graph for the monitoring object exist
*
2014-09-04 13:31:04 +02:00
* @param MonitoredObject $object
*
* @return bool
*/
2014-09-04 13:31:04 +02:00
abstract public function has(MonitoredObject $object);
/**
2014-09-04 13:31:04 +02:00
* Get a preview for the given object
*
2014-09-04 13:31:04 +02:00
* This function must return an empty string if no graph exists.
*
2014-09-04 13:31:04 +02:00
* @param MonitoredObject $object
*
2014-09-04 13:31:04 +02:00
* @return string
* @throws ProgrammingError
2014-09-04 13:31:04 +02:00
*
*/
2014-09-04 13:31:04 +02:00
public function getPreviewHtml(MonitoredObject $object)
{
2014-09-04 13:31:04 +02:00
throw new ProgrammingError('This hook provide previews but it is not implemented');
}
2014-09-04 13:31:04 +02:00
/**
2014-09-04 13:31:04 +02:00
* Get a tiny preview for the given object
*
2014-09-04 13:31:04 +02:00
* This function must return an empty string if no graph exists.
*
2014-09-04 13:31:04 +02:00
* @param MonitoredObject $object
*
* @return string
2014-09-04 13:31:04 +02:00
* @throws ProgrammingError
*/
2014-09-04 13:31:04 +02:00
public function getTinyPreviewHtml(MonitoredObject $object)
{
throw new ProgrammingError('This hook provide tiny previews but it is not implemented');
}
}