Start specialized dir_role mapping for special packages ("horde" for a start).
authorGunnar Wrobel <p@rdus.de>
Tue, 2 Nov 2010 20:53:17 +0000 (21:53 +0100)
committerGunnar Wrobel <p@rdus.de>
Tue, 2 Nov 2010 20:54:12 +0000 (21:54 +0100)
components/lib/Components/Pear/Package/Contents/Factory.php

index 655b8fc..caea08c 100644 (file)
@@ -41,18 +41,7 @@ class Components_Pear_Package_Contents_Factory
         $root = new Components_Helper_Root(
             $package->_options['packagedirectory']
         );
-        $package->_options['dir_roles'] = array(
-            'bin'       => 'script',
-            'script'    => 'script',
-            'doc'       => 'doc',
-            'example'   => 'doc',
-            'js'        => 'horde',
-            'horde'     => 'horde',
-            'lib'       => 'php',
-            'migration' => 'data',
-            'scripts'   => 'data',
-            'test'      => 'test',
-        );
+        $package->_options['dir_roles'] = $this->_getMapping($root->getBase());
         return new Components_Pear_Package_Contents_List(
             $package->_options['packagedirectory'],
             new Components_Pear_Package_Contents_Ignore(
@@ -61,4 +50,48 @@ class Components_Pear_Package_Contents_Factory
             )
         );
     }
+
+    /**
+     * Return the directory <-> role mapping for the specific package.
+     *
+     * @param string $path The package path.
+     *
+     * @return array The mapping.
+     */
+    private function _getMapping($path)
+    {
+        switch ($path) {
+        case 'horde/':
+            return array(
+                'admin'     => 'horde',
+                'bin'       => 'script',
+                'config'    => 'horde',
+                'script'    => 'script',
+                'docs'      => 'doc',
+                'js'        => 'horde',
+                'lib'       => 'horde',
+                'scripts'   => 'data',
+                'services'  => 'horde',
+                'test'      => 'test',
+                'templates' => 'horde',
+                'themes'    => 'horde',
+                'util'      => 'horde',
+            );
+            break;
+        default:
+            return array(
+                'bin'       => 'script',
+                'script'    => 'script',
+                'doc'       => 'doc',
+                'example'   => 'doc',
+                'js'        => 'horde',
+                'horde'     => 'horde',
+                'lib'       => 'php',
+                'migration' => 'data',
+                'scripts'   => 'data',
+                'test'      => 'test',
+            );
+            break;
+        }
+    }
 }
\ No newline at end of file