[icinga-checkins] icinga.org: icingaweb2/feature/announce-banner-11198: Revert " Implement AnnounceHook"

git at icinga.org git at icinga.org
Fri Nov 4 14:30:55 CET 2016


Module: icingaweb2
Branch: feature/announce-banner-11198
Commit: 9172dfb9a631e5b1014ba857fba772a58dd065b9
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=9172dfb9a631e5b1014ba857fba772a58dd065b9

Author: Alexander A. Klimov <alexander.klimov at icinga.com>
Date:   Fri Nov  4 14:29:17 2016 +0100

Revert "Implement AnnounceHook"

This reverts commit 2c80167224f96f7b6a9f550386db08b645590b48.

refs #11198

---

 .../Icinga/Application/Hook/AnnouncementHook.php   |   79 --------------------
 1 file changed, 79 deletions(-)

diff --git a/library/Icinga/Application/Hook/AnnouncementHook.php b/library/Icinga/Application/Hook/AnnouncementHook.php
deleted file mode 100644
index 049b5fa..0000000
--- a/library/Icinga/Application/Hook/AnnouncementHook.php
+++ /dev/null
@@ -1,79 +0,0 @@
-<?php
-/* Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */
-
-namespace Icinga\Application\Hook;
-
-use Icinga\Exception\ProgrammingError;
-use Icinga\Web\Announcement;
-
-/**
- * Base class for announcement hooks
- *
- * Extend this class if you want your module to provide announcements.
- */
-abstract class AnnouncementHook
-{
-    /**
-     * Cache for {@link getAnnouncements()}
-     *
-     * @var Announcement[]
-     */
-    private $announcements = null;
-
-    /**
-     * AnnouncementHook constructor
-     *
-     * @see {@link init()} for hook initialization.
-     */
-    final public function __construct()
-    {
-        $this->init();
-    }
-
-    /**
-     * Overwrite this function for hook initialization, e.g. loading the hook's config
-     */
-    protected function init()
-    {
-    }
-
-    /**
-     * Get all new announcements
-     *
-     * @return Announcement[]
-     */
-    abstract protected function loadAnnouncements();
-
-    /**
-     * Call {@link loadAnnouncements()} and validate, cache and return its return value
-     *
-     * @return  Announcement[]
-     *
-     * @throws  ProgrammingError    If {@link loadAnnouncements()} returns something invalid
-     */
-    final public function getAnnouncements()
-    {
-        if ($this->announcements === null) {
-            $announcements = $this->loadAnnouncements();
-            if (! is_array($announcements)) {
-                throw new ProgrammingError(
-                    '%s::loadAnnouncements() returned a %s, expected Icinga\Web\Announcement[]',
-                    get_class($this),
-                    is_object($announcements) ? get_class($announcements) : gettype($announcements)
-                );
-            }
-            foreach ($announcements as $announcement) {
-                if (! ($announcement instanceof Announcement)) {
-                    throw new ProgrammingError(
-                        '%s::loadAnnouncements() returned an array with a %s, expected only Icinga\Web\Announcement',
-                        get_class($this),
-                        is_object($announcement) ? get_class($announcement) : gettype($announcement)
-                    );
-                }
-            }
-            $this->announcements = $announcements;
-        }
-
-        return $this->announcements;
-    }
-}



More information about the icinga-checkins mailing list