summaryrefslogtreecommitdiffstats
path: root/library/Reporting/Hook/ReportHook.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:46:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:46:47 +0000
commit4ada86876033fa171e2896d7e3d3c5645d8062db (patch)
treef0d1fee61877df200ccfb1c0af58a39cd551fb46 /library/Reporting/Hook/ReportHook.php
parentInitial commit. (diff)
downloadicingaweb2-module-reporting-4ada86876033fa171e2896d7e3d3c5645d8062db.tar.xz
icingaweb2-module-reporting-4ada86876033fa171e2896d7e3d3c5645d8062db.zip
Adding upstream version 0.10.0.upstream/0.10.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Reporting/Hook/ReportHook.php')
-rw-r--r--library/Reporting/Hook/ReportHook.php116
1 files changed, 116 insertions, 0 deletions
diff --git a/library/Reporting/Hook/ReportHook.php b/library/Reporting/Hook/ReportHook.php
new file mode 100644
index 0000000..13cc01e
--- /dev/null
+++ b/library/Reporting/Hook/ReportHook.php
@@ -0,0 +1,116 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Hook;
+
+use Icinga\Application\ClassLoader;
+use Icinga\Application\Hook;
+use Icinga\Module\Reporting\ReportData;
+use Icinga\Module\Reporting\Timerange;
+use ipl\Html\Form;
+use ipl\Html\ValidHtml;
+
+abstract class ReportHook
+{
+ /**
+ * Get the name of the report
+ *
+ * @return string
+ */
+ abstract public function getName();
+
+ /**
+ * @param Timerange $timerange
+ * @param array $config
+ *
+ * @return ReportData|null
+ */
+ public function getData(Timerange $timerange, array $config = null)
+ {
+ return null;
+ }
+
+ /**
+ * Get the HTML of the report
+ *
+ * @param Timerange $timerange
+ * @param array $config
+ *
+ * @return ValidHtml|null
+ */
+ public function getHtml(Timerange $timerange, array $config = null)
+ {
+ return null;
+ }
+
+ /**
+ * Initialize the report's configuration form
+ *
+ * @param Form $form
+ */
+ public function initConfigForm(Form $form)
+ {
+ }
+
+ /**
+ * Get the description of the report
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return null;
+ }
+
+ /**
+ * Get whether the report provides reporting data
+ *
+ * @return bool
+ */
+ public function providesData()
+ {
+ try {
+ $method = new \ReflectionMethod($this, 'getData');
+ } catch (\ReflectionException $e) {
+ return false;
+ }
+
+ return $method->getDeclaringClass()->getName() !== self::class;
+ }
+
+ /**
+ * Get whether the report provides HTML
+ *
+ * @return bool
+ */
+ public function providesHtml()
+ {
+ try {
+ $method = new \ReflectionMethod($this, 'getHtml');
+ } catch (\ReflectionException $e) {
+ return false;
+ }
+
+ return $method->getDeclaringClass()->getName() !== self::class;
+ }
+
+ /**
+ * Get the module name of the report
+ *
+ * @return string
+ */
+ final public function getModuleName()
+ {
+ return ClassLoader::extractModuleName(get_class($this));
+ }
+
+ /**
+ * Get all provided reports
+ *
+ * @return ReportHook[]
+ */
+ final public static function getReports()
+ {
+ return Hook::all('reporting/Report');
+ }
+}