[icinga-checkins] icinga.org: icingaweb2/master: Load resources from config automatically instead of throwing an exception

git at icinga.org git at icinga.org
Fri Feb 26 12:31:15 CET 2016


Module: icingaweb2
Branch: master
Commit: e4a0678df01ee26eb5969316bdc04e765f99e582
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=e4a0678df01ee26eb5969316bdc04e765f99e582

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Fri Feb 26 12:29:30 2016 +0100

Load resources from config automatically instead of throwing an exception

fixes #10918

---

 library/Icinga/Application/ApplicationBootstrap.php |   19 -------------------
 library/Icinga/Application/Cli.php                  |    1 -
 library/Icinga/Application/Web.php                  |    1 -
 library/Icinga/Data/ResourceFactory.php             |    6 ++----
 4 files changed, 2 insertions(+), 25 deletions(-)

diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php
index c14f588..7f0a51b 100644
--- a/library/Icinga/Application/ApplicationBootstrap.php
+++ b/library/Icinga/Application/ApplicationBootstrap.php
@@ -521,25 +521,6 @@ abstract class ApplicationBootstrap
     }
 
     /**
-     * Set up the resource factory
-     *
-     * @return $this
-     */
-    protected function setupResourceFactory()
-    {
-        try {
-            $config = Config::app('resources');
-            ResourceFactory::setConfig($config);
-        } catch (NotReadableError $e) {
-            Logger::error(
-                new IcingaException('Cannot load resource configuration. An exception was thrown:', $e)
-            );
-        }
-
-        return $this;
-    }
-
-    /**
      * Set up the user backend factory
      *
      * @return  $this
diff --git a/library/Icinga/Application/Cli.php b/library/Icinga/Application/Cli.php
index 4fa8bf0..1ef90e2 100644
--- a/library/Icinga/Application/Cli.php
+++ b/library/Icinga/Application/Cli.php
@@ -41,7 +41,6 @@ class Cli extends ApplicationBootstrap
             ->setupInternationalization()
             ->parseBasicParams()
             ->setupLogger()
-            ->setupResourceFactory()
             ->setupModuleManager()
             ->setupUserBackendFactory()
             ->loadSetupModuleIfNecessary();
diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php
index 7104080..02f0aa9 100644
--- a/library/Icinga/Application/Web.php
+++ b/library/Icinga/Application/Web.php
@@ -82,7 +82,6 @@ class Web extends EmbeddedWeb
             ->setupLogging()
             ->setupErrorHandling()
             ->loadConfig()
-            ->setupResourceFactory()
             ->setupSession()
             ->setupNotifications()
             ->setupRequest()
diff --git a/library/Icinga/Data/ResourceFactory.php b/library/Icinga/Data/ResourceFactory.php
index 46c1146..cf42496 100644
--- a/library/Icinga/Data/ResourceFactory.php
+++ b/library/Icinga/Data/ResourceFactory.php
@@ -67,16 +67,14 @@ class ResourceFactory implements ConfigAwareFactory
     }
 
     /**
-     * Check if the existing resources are set. If not, throw an error.
+     * Check if the existing resources are set. If not, load them from resources.ini
      *
      * @throws  ConfigurationError
      */
     private static function assertResourcesExist()
     {
         if (self::$resources === null) {
-            throw new ConfigurationError(
-                'Resources not set up. Please contact your Icinga Web administrator'
-            );
+            self::$resources = Config::app('resources');
         }
     }
 



More information about the icinga-checkins mailing list