[icinga-checkins] icinga.org: icinga-web/master: * Fixed encapuslation errors

git at icinga.org git at icinga.org
Tue Apr 24 15:01:14 CEST 2012


Module: icinga-web
Branch: master
Commit: f746898cd3e70db571bc1d7ce5f8ccb538ccc67d
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=f746898cd3e70db571bc1d7ce5f8ccb538ccc67d

Author: Jannis Mosshammer <jannis.mosshammer at netways.de>
Date:   Thu Mar  1 18:25:46 2012 +0100

* Fixed encapuslation errors

---

 .../lib/template/CronkGridTemplateWorker.class.php |   15 ++++++++++++---
 .../DQLCronkTemplateWorker.class.php               |    8 ++------
 .../GenericCronkTemplateWorker.class.php           |   13 ++++---------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/app/modules/Cronks/lib/template/CronkGridTemplateWorker.class.php b/app/modules/Cronks/lib/template/CronkGridTemplateWorker.class.php
index f48ef49..f423e62 100644
--- a/app/modules/Cronks/lib/template/CronkGridTemplateWorker.class.php
+++ b/app/modules/Cronks/lib/template/CronkGridTemplateWorker.class.php
@@ -1,10 +1,12 @@
 <?php
 
 abstract class CronkGridTemplateWorker {
+    /**
+     * @var AgaviContext
+     */
+    private $context         = null;
     
     abstract public function __construct(CronkGridTemplateXmlParser $template, AgaviContext $context);
-    
-    abstract public function setContext(AgaviContext $context);
 
     abstract public function setTemplate(CronkGridTemplateXmlParser $template);
 
@@ -35,6 +37,13 @@ abstract class CronkGridTemplateWorker {
      */
     abstract public function setCondition($field, $val, $op = null);
 
+    public function setContext(AgaviContext $context) {
+        $this->context = $context;
+    }
+
+    public function getContext() {
+        return $this->context;
+    }
     /**
      *
      * TODO: API CALL CHANGE
@@ -121,7 +130,7 @@ abstract class CronkGridTemplateWorker {
 
     protected function rewritePerClassMethod($model, $method, $data_val, array $params = array(), array $row = array()) {
         list($module, $model) = explode('.', $model, 2);
-        $modelObject = $this->context->getModel($model, $module);
+        $modelObject = $this->getContext()->getModel($model, $module);
         return $modelObject->$method($data_val, new AgaviParameterHolder($params), new AgaviParameterHolder($row));
     }
 
diff --git a/app/modules/Cronks/lib/template/TemplateWorker/DQLCronkTemplateWorker.class.php b/app/modules/Cronks/lib/template/TemplateWorker/DQLCronkTemplateWorker.class.php
index 7abdf7e..aac724b 100644
--- a/app/modules/Cronks/lib/template/TemplateWorker/DQLCronkTemplateWorker.class.php
+++ b/app/modules/Cronks/lib/template/TemplateWorker/DQLCronkTemplateWorker.class.php
@@ -13,7 +13,6 @@ class DQLCronkTemplateWorker extends CronkGridTemplateWorker {
     private $template;
 
     private $user;
-    private $context;
     private $parser;
     private $offset = 0;
     private $limit = 0;
@@ -28,9 +27,9 @@ class DQLCronkTemplateWorker extends CronkGridTemplateWorker {
     public function __construct(CronkGridTemplateXmlParser $template, AgaviContext $context) {
         $this->setTemplate($template);
         $this->setContext($context);
-        $this->user = $this->context->getUser()->getNsmUser();
+        $this->user = $context->getUser()->getNsmUser();
         $view = $this->readDataSourceDefinition();
-        $this->parser = $this->context->getModel("Views.ApiDQLView","Api",array(
+        $this->parser = $context->getModel("Views.ApiDQLView","Api",array(
             "view" => $view
         ));
         /**
@@ -40,9 +39,6 @@ class DQLCronkTemplateWorker extends CronkGridTemplateWorker {
 
     }
     
-    public function setContext(AgaviContext $context) {
-        $this->context = $context;
-    }
 
     public function setTemplate(CronkGridTemplateXmlParser $template) {
         $this->template = $template;
diff --git a/app/modules/Cronks/lib/template/TemplateWorker/GenericCronkTemplateWorker.class.php b/app/modules/Cronks/lib/template/TemplateWorker/GenericCronkTemplateWorker.class.php
index cda03f2..c7f9ee5 100644
--- a/app/modules/Cronks/lib/template/TemplateWorker/GenericCronkTemplateWorker.class.php
+++ b/app/modules/Cronks/lib/template/TemplateWorker/GenericCronkTemplateWorker.class.php
@@ -16,10 +16,7 @@ class GenericCronkTemplateWorker extends CronkGridTemplateWorker {
      */
     private $template        = null;
 
-    /**
-     * @var AgaviContext
-     */
-    private $context         = null;
+   
 
     /**
      * @var IcingaApiConnectionIdo
@@ -72,8 +69,8 @@ class GenericCronkTemplateWorker extends CronkGridTemplateWorker {
 
         if ($context) {
             $this->setContext($context);
-            $this->api = $this->context->getModel('Icinga.ApiContainer', 'Web')->getConnection();
-            $this->user= $this->context->getUser()->getNsmUser();
+            $this->api = $context->getModel('Icinga.ApiContainer', 'Web')->getConnection();
+            $this->user= $context->getUser()->getNsmUser();
         }
     }
 
@@ -81,9 +78,7 @@ class GenericCronkTemplateWorker extends CronkGridTemplateWorker {
         $this->template = $template;
     }
 
-    public function setContext(AgaviContext $context) {
-        $this->context = $context;
-    }
+   
 
     public function setApi(/*IcingaApi*/ $api) {
         $this->api = $api;





More information about the icinga-checkins mailing list