[icinga-checkins] icinga.org: icingaweb2/master: Setup/Webserver: Change template generation to nowdoc

git at icinga.org git at icinga.org
Thu Nov 13 15:10:31 CET 2014


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

Author: Marius Hein <marius.hein at netways.de>
Date:   Fri Nov  7 09:18:16 2014 +0100

Setup/Webserver: Change template generation to nowdoc

refs #6120

---

 library/Icinga/Web/Setup/Webserver/Apache2.php   |   21 +++++++--------
 library/Icinga/Web/Setup/Webserver/Apache24.php  |   17 +++++++-----
 library/Icinga/Web/Setup/Webserver/Nginx.php     |   30 ++++++++++------------
 library/Icinga/Web/Setup/Webserver/Webserver.php |    6 ++---
 4 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/library/Icinga/Web/Setup/Webserver/Apache2.php b/library/Icinga/Web/Setup/Webserver/Apache2.php
index 49db80e..846dc0a 100644
--- a/library/Icinga/Web/Setup/Webserver/Apache2.php
+++ b/library/Icinga/Web/Setup/Webserver/Apache2.php
@@ -14,15 +14,16 @@ class Apache2 extends Webserver
      */
     protected function getTemplate()
     {
-        return array(
-            'Alias {webPath} {publicPath}',
-            '<directory {publicPath}>',
-            '  Options -Indexes',
-            '  AllowOverride All',
-            '  Order allow,deny',
-            '  Allow from all',
-            '  EnableSendfile Off',
-            '</directory>'
-        );
+            return  <<<'EOD'
+Alias {webPath} {publicPath}
+<directory {publicPath}>
+  Options -Indexes
+  AllowOverride All
+  Order allow,deny
+  Allow from all
+  EnableSendfile Off
+</directory>
+EOD;
+
     }
 }
diff --git a/library/Icinga/Web/Setup/Webserver/Apache24.php b/library/Icinga/Web/Setup/Webserver/Apache24.php
index 29e9277..c9992e7 100644
--- a/library/Icinga/Web/Setup/Webserver/Apache24.php
+++ b/library/Icinga/Web/Setup/Webserver/Apache24.php
@@ -7,7 +7,7 @@ namespace Icinga\Web\Setup\Webserver;
 /**
  * Generate apache2.4 configuration
  */
-class Apache24 extends Apache2
+class Apache24 extends Webserver
 {
     /**
      * Use default template and change granted syntax for 2.4
@@ -16,11 +16,14 @@ class Apache24 extends Apache2
      */
     protected function getTemplate()
     {
-        $template = parent::getTemplate();
-        $replace = array(
-            '  Require all granted'
-        );
-        array_splice($template, count($template)-4, 2, $replace);
-        return $template;
+        return  <<<'EOD'
+Alias {webPath} {publicPath}
+<directory {publicPath}>
+  Options -Indexes
+  AllowOverride All
+  Require all granted
+  EnableSendfile Off
+</directory>
+EOD;
     }
 }
diff --git a/library/Icinga/Web/Setup/Webserver/Nginx.php b/library/Icinga/Web/Setup/Webserver/Nginx.php
index 90996b2..decd7dd 100644
--- a/library/Icinga/Web/Setup/Webserver/Nginx.php
+++ b/library/Icinga/Web/Setup/Webserver/Nginx.php
@@ -16,22 +16,20 @@ class Nginx extends Webserver
      */
     protected function getTemplate()
     {
-        return array(
-            'location ~ ^{webPath}/index\.php(.*)$ {',
-            '  # fastcgi_pass 127.0.0.1:9000;',
-            '  fastcgi_pass unix:/var/run/php5-fpm.sock;',
-            '  fastcgi_index index.php;',
-            '  include fastcgi_params;',
-            '  fastcgi_param SCRIPT_FILENAME {publicPath}/index.php;',
-            '}',
-
-
+        return <<<'EOD'
+location ~ ^{webPath}/index\.php(.*)$ {
+  # fastcgi_pass 127.0.0.1:9000;
+  fastcgi_pass unix:/var/run/php5-fpm.sock;
+  fastcgi_index index.php;
+  include fastcgi_params;
+  fastcgi_param SCRIPT_FILENAME {publicPath}/index.php;
+}
 
-            'location ~ ^{webPath} {',
-            '  alias {publicPath};',
-            '  index index.php;',
-            '  try_files $uri $uri/ {webPath}/index.php$is_args$args;',
-            '}',
-        );
+location ~ ^{webPath} {
+  alias {publicPath};
+  index index.php;
+  try_files $uri $uri/ {webPath}/index.php$is_args$args;
+}
+EOD;
     }
 }
diff --git a/library/Icinga/Web/Setup/Webserver/Webserver.php b/library/Icinga/Web/Setup/Webserver/Webserver.php
index b246cff..56ade84 100644
--- a/library/Icinga/Web/Setup/Webserver/Webserver.php
+++ b/library/Icinga/Web/Setup/Webserver/Webserver.php
@@ -66,9 +66,7 @@ abstract class Webserver
     public function generate()
     {
         $template = $this->getTemplate();
-        if (is_array($template)) {
-            $template = implode(PHP_EOL, $template);
-        }
+
         $searchTokens = array(
             '{webPath}',
             '{publicPath}'
@@ -84,7 +82,7 @@ abstract class Webserver
     /**
      * Specific template
      *
-     * @return array|string
+     * @return string
      */
     abstract protected function getTemplate();
 



More information about the icinga-checkins mailing list