Development

#3056 (patch to allow customisation of decorator directory)

You must first sign up to be able to contribute.

Ticket #3056 (closed defect: fixed)

Opened 9 months ago

Last modified 9 months ago

patch to allow customisation of decorator directory

Reported by: pookey Assigned to: fabien
Priority: minor Milestone: 1.1.0
Component: other Version: 1.1.0 DEV
Keywords: Cc:
Qualification: Design decision

Description

Index: lib/config/sfApplicationConfiguration.class.php
===================================================================
--- lib/config/sfApplicationConfiguration.class.php     (revision 7748)
+++ lib/config/sfApplicationConfiguration.class.php     (working copy)
@@ -341,6 +341,19 @@
   }

   /**
+   * Gets the decorator directroy for a given template
+   *
+   * @param string The tempalte file
+   *
+   * @return string A tempalte path
+   *
+   */
+  public function getDecoratorDir($template)
+  {
+    return sfConfig::get('sf_app_template_dir');
+  }
+
+  /**
    * Gets the i18n directories to use globally.
    *
    * @return array An array of i18n directories
Index: lib/view/sfView.class.php
===================================================================
--- lib/view/sfView.class.php   (revision 7748)
+++ lib/view/sfView.class.php   (working copy)
@@ -128,8 +128,6 @@
     $this->parameterHolder = new sfParameterHolder();
     $this->parameterHolder->add(sfConfig::get('mod_'.strtolower($moduleName).'_view_param', array()));

-    $this->decoratorDirectory = sfConfig::get('sf_app_template_dir');
-
     // include view configuration
     $this->configure();

@@ -378,6 +376,7 @@
     }
     else
     {
+      $this->decoratorDirectory = $this->context->getConfiguration()->getDecoratorDir($template);
       $this->decoratorTemplate = $template;
     }

Change History

03/07/08 14:58:24 changed by pookey

Index: lib/config/sfApplicationConfiguration.class.php
===================================================================
--- lib/config/sfApplicationConfiguration.class.php     (revision 7748)
+++ lib/config/sfApplicationConfiguration.class.php     (working copy)
@@ -341,6 +341,37 @@
   }

   /**
+   * Gets the decorator directroies
+   *
+   * @param string The tempalte file
+   *
+   * @return array An array of teh decorator directories
+   *
+   */
+  public function getDecoratorDirs($template)
+  {
+    return array(sfConfig::get('sf_app_template_dir'));
+  }
+
+  /**
+   * Gets the decorater directory for a given template
+   *
+   * @param string The template file
+   *
+   * @return string A template directory
+   */
+  public function getDecoratorDir($template)
+  {
+    foreach ($this->getDecoratorDirs($template) as $dir)
+    {
+      if (is_readable($dir))
+      {
+        return $dir;
+      }
+    }
+  }
+
+  /**
    * Gets the i18n directories to use globally.
    *
    * @return array An array of i18n directories
@@ -361,7 +392,6 @@
     {
       $dirs[] = $pluginDirs[0];
     }
-
     return $dirs;
   }

Index: lib/view/sfView.class.php
===================================================================
--- lib/view/sfView.class.php   (revision 7748)
+++ lib/view/sfView.class.php   (working copy)
@@ -128,8 +128,6 @@
     $this->parameterHolder = new sfParameterHolder();
     $this->parameterHolder->add(sfConfig::get('mod_'.strtolower($moduleName).'_view_param', array()));

-    $this->decoratorDirectory = sfConfig::get('sf_app_template_dir');
-
     // include view configuration
     $this->configure();

@@ -378,6 +376,7 @@
     }
     else
     {
+      $this->decoratorDirectory = $this->context->getConfiguration()->getDecoratorDir($template);
       $this->decoratorTemplate = $template;
     }


03/07/08 17:48:29 changed by pookey

  • qualification changed from Unreviewed to Design decision.
  • milestone set to 1.1.0.

3rd time lucky maybe? :)

This one doesn't fail any tests, wooo.

Let me know if it's ok, and I'll commit it

Index: lib/config/sfApplicationConfiguration.class.php
===================================================================
--- lib/config/sfApplicationConfiguration.class.php     (revision 7748)
+++ lib/config/sfApplicationConfiguration.class.php     (working copy)
@@ -341,6 +341,37 @@
   }

   /**
+   * Gets the decorator directroies
+   *
+   * @param string The tempalte file
+   *
+   * @return array An array of the decorator directories
+   *
+   */
+  public function getDecoratorDirs()
+  {
+    return array(sfConfig::get('sf_app_template_dir'));
+  }
+
+  /**
+   * Gets the decorater directory for a given template
+   *
+   * @param string The template file
+   *
+   * @return string A template directory
+   */
+  public function getDecoratorDir($template)
+  {
+    foreach ($this->getDecoratorDirs() as $dir)
+    {
+      if (is_readable($dir.'/'.$template))
+      {
+        return $dir;
+      }
+    }
+  }
+
+  /**
    * Gets the i18n directories to use globally.
    *
    * @return array An array of i18n directories
@@ -361,7 +392,6 @@
     {
       $dirs[] = $pluginDirs[0];
     }
-
     return $dirs;
   }

Index: lib/view/sfView.class.php
===================================================================
--- lib/view/sfView.class.php   (revision 7748)
+++ lib/view/sfView.class.php   (working copy)
@@ -371,6 +371,11 @@
       return;
     }

+    if (!strpos($template, '.'))
+    {
+      $template .= $this->getExtension();
+    }
+
     if (sfToolkit::isPathAbsolute($template))
     {
       $this->decoratorDirectory = dirname($template);
@@ -378,14 +383,10 @@
     }
     else
     {
+      $this->decoratorDirectory = $this->context->getConfiguration()->getDecoratorDir($template);
       $this->decoratorTemplate = $template;
     }

-    if (!strpos($this->decoratorTemplate, '.'))
-    {
-      $this->decoratorTemplate .= $this->getExtension();
-    }
-
     // set decorator status
     $this->decorator = true;
   }

03/12/08 23:54:31 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.

in r7846