[icinga-checkins] icinga.org: icingaweb2/feature/ inirepository-should-support-multiple-tables-13034: Repository: allow not to provide a datasource for all tables

git at icinga.org git at icinga.org
Thu Nov 3 18:10:42 CET 2016


Module: icingaweb2
Branch: feature/inirepository-should-support-multiple-tables-13034
Commit: 38602379be8ed8de7f367c0fa4b258c5593baacf
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=38602379be8ed8de7f367c0fa4b258c5593baacf

Author: Alexander A. Klimov <alexander.klimov at icinga.com>
Date:   Thu Nov  3 16:12:09 2016 +0100

Repository: allow not to provide a datasource for all tables

refs #13034

---

 library/Icinga/Repository/Repository.php |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/library/Icinga/Repository/Repository.php b/library/Icinga/Repository/Repository.php
index 1d111b4..73721c0 100644
--- a/library/Icinga/Repository/Repository.php
+++ b/library/Icinga/Repository/Repository.php
@@ -214,9 +214,10 @@ abstract class Repository implements Selectable
     /**
      * Create a new repository object
      *
-     * @param   Selectable  $ds     The datasource to use
+     * @param   Selectable|null $ds The datasource to use.
+     *                              Only pass null if you have overridden {@link getDataSource()}!
      */
-    public function __construct(Selectable $ds)
+    public function __construct(Selectable $ds = null)
     {
         $this->ds = $ds;
         $this->aliasTableMap = array();
@@ -271,6 +272,9 @@ abstract class Repository implements Selectable
      */
     public function getDataSource($table = null)
     {
+        if ($this->ds === null) {
+            throw new ProgrammingError('No data source available');
+        }
         return $this->ds;
     }
 



More information about the icinga-checkins mailing list