[icinga-checkins] icinga.org: icingaweb2-module-director/bugfix/loop-templateresolver-11803: QuickBaseForm: allow for multiple module-related...

git at icinga.org git at icinga.org
Mon Oct 31 13:31:44 CET 2016


Module: icingaweb2-module-director
Branch: bugfix/loop-templateresolver-11803
Commit: 27634fe722db2bc9dd908ed15a824cb24cc8c7c2
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=27634fe722db2bc9dd908ed15a824cb24cc8c7c2

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu Oct 27 18:17:21 2016 +0000

QuickBaseForm: allow for multiple module-related...

...prefix paths

---

 library/Director/Web/Form/QuickBaseForm.php |   47 +++++++++++++++++++--------
 1 file changed, 33 insertions(+), 14 deletions(-)

diff --git a/library/Director/Web/Form/QuickBaseForm.php b/library/Director/Web/Form/QuickBaseForm.php
index 631733b..d3d1610 100644
--- a/library/Director/Web/Form/QuickBaseForm.php
+++ b/library/Director/Web/Form/QuickBaseForm.php
@@ -2,6 +2,7 @@
 
 namespace Icinga\Module\Director\Web\Form;
 
+use Icinga\Application\Icinga;
 use Icinga\Application\Modules\Module;
 use Zend_Form;
 
@@ -29,23 +30,41 @@ abstract class QuickBaseForm extends Zend_Form
 
     protected function initializePrefixPaths()
     {
-        if ($this->icingaModule) {
-            $basedir = sprintf(
-                '%s/%s/Web/Form',
-                $this->icingaModule->getLibDir(),
-                ucfirst($this->icingaModuleName)
-            );
-
-            $this->addPrefixPaths(array(
-                array(
-                    'prefix'    => __NAMESPACE__ . '\\Element\\',
-                    'path'      => $basedir . '/Element',
-                    'type'      => static::ELEMENT
-                )
-            ));
+        $this->addPrefixPathsForDirector();
+        if ($this->icingaModule && $this->icingaModuleName !== 'director') {
+            $this->addPrefixPathsForModule($this->icingaModule);
         }
     }
 
+    protected function addPrefixPathsForDirector()
+    {
+        $module = Icinga::app()
+            ->getModuleManager()
+            ->loadModule('director')
+            ->getModule('director');
+
+        $this->addPrefixPathsForModule($module);
+    }
+
+    public function addPrefixPathsForModule(Module $module)
+    {
+        $basedir = sprintf(
+            '%s/%s/Web/Form',
+            $module->getLibDir(),
+            ucfirst($module->getName())
+        );
+
+        $this->addPrefixPaths(array(
+            array(
+                'prefix'    => __NAMESPACE__ . '\\Element\\',
+                'path'      => $basedir . '/Element',
+                'type'      => static::ELEMENT
+            )
+        ));
+
+        return $this;
+    }
+
     public function addHidden($name, $value = null)
     {
         $this->addElement('hidden', $name);



More information about the icinga-checkins mailing list