Author: caefer
Date: 2010-05-07 15:41:57 +0200 (Fri, 07 May 2010)
New Revision: 29385

Added:
   plugins/sfImageTransformExtraPlugin/trunk/config/app.yml
Modified:
   
plugins/sfImageTransformExtraPlugin/trunk/lib/transforms/sfImageTransformManager.class.php
Log:
added a way to add custom resource locations for overlays and alpha masks

Added: plugins/sfImageTransformExtraPlugin/trunk/config/app.yml
===================================================================
--- plugins/sfImageTransformExtraPlugin/trunk/config/app.yml                    
        (rev 0)
+++ plugins/sfImageTransformExtraPlugin/trunk/config/app.yml    2010-05-07 
13:41:57 UTC (rev 29385)
@@ -0,0 +1,12 @@
+# sfImageTransFormExtraPlugin will look up resource files such as overlays and 
alpha masks in
+# %SF_DATA_DIR%/resources/ and 
%SF_PLUGINS_DIR%/sfImageTransFormExtraPlugin/data/example-resources
+# by default. If you wish to extend this list you can use the following 
settings in you app.yml to
+# add more paths containing your resource files. These paths will have higher 
priority than the
+# default ones. Be aware that absolute paths need to be accessible by the web 
server.
+#
+#all:
+#  sfImageTransformExtraPlugin:
+#    additional_resource_paths:
+#      - %SF_PLUGINS_DIR%/yourResourcesPlugin/data/resources
+#      - /absolute/path/to/your/resources
+#

Modified: 
plugins/sfImageTransformExtraPlugin/trunk/lib/transforms/sfImageTransformManager.class.php
===================================================================
--- 
plugins/sfImageTransformExtraPlugin/trunk/lib/transforms/sfImageTransformManager.class.php
  2010-05-07 10:00:04 UTC (rev 29384)
+++ 
plugins/sfImageTransformExtraPlugin/trunk/lib/transforms/sfImageTransformManager.class.php
  2010-05-07 13:41:57 UTC (rev 29385)
@@ -143,14 +143,20 @@
       $pluginDirs = ProjectConfiguration::getActive()->getAllPluginPaths();
       $pluginDir = $pluginDirs['sfImageTransformExtraPlugin'];
 
+      $resourcePaths = array_merge(
+        
sfConfig::get('app_sfImageTransformExtraPlugin_additional_resource_paths', 
array()),
+        array(
+          sfConfig::get('sf_data_dir') . '/resources/',
+          $pluginDir . '/data/example-resources/'
+        )
+      );
+
+      array_walk($resourcePaths, array($this, 'extendResourcePaths'), 
$filepath);
+
       $files = sfFinder::type('file')
         ->name($filename)
         ->maxdepth(1)
-        ->in(array(
-          sfConfig::get('sf_data_dir') . '/resources/'.$filepath,
-          $pluginDir . '/data/example-resources/'.$filepath,
-        )
-      );
+        ->in($resourcePaths);
 
       if(0 == count($files))
       {
@@ -162,4 +168,19 @@
 
     return $parameter;
   }
+
+  /**
+   * Extending known resource paths (from app.yml) with current filepath
+   * Used as callback for array_walk in 
sfImageTransformManager::autoboxSfImage()
+   * @see array_merge()
+   *
+   * @param  string &$path         One of the resource path as configured in 
app.yml
+   * @param  string $index         Current key/index
+   * @param  string $pathExtension The current filepath to look up
+   * @return string
+   */
+  public function extendResourcePaths(&$path, $index, $pathExtension)
+  {
+    $path = $path.'/'.$pathExtension;
+  }
 }

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to