Author: lindner
Date: Mon Jul 19 08:12:23 2010
New Revision: 965382

URL: http://svn.apache.org/viewvc?rev=965382&view=rev
Log:
SHINDIG-1386 | Patch from Bastian Hofmann | Allow additional javascript feature 
directories e.g. in the extras folder

Modified:
    shindig/trunk/php/config/container.php
    shindig/trunk/php/src/gadgets/GadgetContext.php
    shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php

Modified: shindig/trunk/php/config/container.php
URL: 
http://svn.apache.org/viewvc/shindig/trunk/php/config/container.php?rev=965382&r1=965381&r2=965382&view=diff
==============================================================================
--- shindig/trunk/php/config/container.php (original)
+++ shindig/trunk/php/config/container.php Mon Jul 19 08:12:23 2010
@@ -114,7 +114,10 @@ $shindigConfig = array(
 
   // The locations of the various required components on disk. If you did a 
normal svn checkout there's no need to change these
   'base_path' => realpath(dirname(__FILE__) . '/..') . '/',
-  'features_path' => realpath(dirname(__FILE__) . 
'/../../features/src/main/javascript/features') . '/',
+  'features_path' => array(
+    realpath(dirname(__FILE__) . 
'/../../features/src/main/javascript/features') . '/',
+    realpath(dirname(__FILE__) . 
'/../../extras/src/main/javascript/features-extras') . '/',
+  ),
   'container_path' => realpath(dirname(__FILE__) . '/../../config') . '/',
   'javascript_path' => realpath(dirname(__FILE__) . '/../../content') . '/',
 

Modified: shindig/trunk/php/src/gadgets/GadgetContext.php
URL: 
http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/GadgetContext.php?rev=965382&r1=965381&r2=965382&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/GadgetContext.php (original)
+++ shindig/trunk/php/src/gadgets/GadgetContext.php Mon Jul 19 08:12:23 2010
@@ -117,9 +117,10 @@ class GadgetContext {
   private function instanceRegistry() {
     // feature parsing is very resource intensive so by caching the result 
this saves upto 30% of the processing time
     $featureCache = Cache::createCache(Config::get('feature_cache'), 
'FeatureCache');
-    if (! ($registry = $featureCache->get(md5(Config::get('features_path'))))) 
{
+    $key = md5(implode(',', Config::get('features_path')));
+    if (! ($registry = $featureCache->get($key))) {
       $registry = new GadgetFeatureRegistry(Config::get('features_path'));
-      $featureCache->set(md5(Config::get('features_path')), $registry);
+      $featureCache->set($key, $registry);
     }
     return $registry;
   }

Modified: shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php
URL: 
http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php?rev=965382&r1=965381&r2=965382&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php (original)
+++ shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php Mon Jul 19 08:12:23 
2010
@@ -25,13 +25,19 @@
  *
  */
 class GadgetFeatureRegistry {
-  public $features;
-  private $coreDone = false;
-  private $coreFeaturs;
+  public $features = array();
+  private $coreFeatures;
   private $sortedFeatures;
   
   public function __construct($featurePath) {
-    $this->registerFeatures($featurePath);
+    if (is_array($featurePath)) {
+      foreach ($featurePath as $path) {
+        $this->registerFeatures($path);
+      }
+    } else {
+      $this->registerFeatures($featurePath);
+    }
+    $this->processFeatures();
   }
 
   public function getFeaturesContent($features, GadgetContext $context, 
$isGadgetContext) {
@@ -134,7 +140,6 @@ class GadgetFeatureRegistry {
    * @param string $featurePath path to scan
    */
   private function registerFeatures($featurePath) {
-    $this->features = array();
     // Load the features from the shindig/features/features.txt file
     $featuresFile = $featurePath . '/features.txt';
     if (File::exists($featuresFile)) {
@@ -149,6 +154,12 @@ class GadgetFeatureRegistry {
         }
       }
     }
+  }
+
+  /**
+   * gets core features and sorts features
+   */
+  private function processFeatures() {
     // Determine the core features
     $this->coreFeatures = array();
     foreach ($this->features as $entry) {


Reply via email to