]> _ Git - couzy.git/blob
673f1fc1f284b1a99a2e0669ee96b9e22474f54d
[couzy.git] /
1 <?php
2 namespace Composer\Installers;
3
4 /**
5  * Plugin/theme installer for shopware
6  * @author Benjamin Boit
7  */
8 class ShopwareInstaller extends BaseInstaller
9 {
10     protected $locations = array(
11         'backend-plugin'    => 'engine/Shopware/Plugins/Local/Backend/{$name}/',
12         'core-plugin'       => 'engine/Shopware/Plugins/Local/Core/{$name}/',
13         'frontend-plugin'   => 'engine/Shopware/Plugins/Local/Frontend/{$name}/',
14         'theme'             => 'templates/{$name}/'
15     );
16
17     /**
18      * Transforms the names
19      * @param  array $vars
20      * @return array
21      */
22     public function inflectPackageVars($vars)
23     {
24         if ($vars['type'] === 'shopware-theme') {
25             return $this->correctThemeName($vars);
26         } else {
27             return $this->correctPluginName($vars);
28         }
29     }
30
31     /**
32      * Changes the name to a camelcased combination of vendor and name
33      * @param  array $vars
34      * @return array
35      */
36     private function correctPluginName($vars)
37     {
38         $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
39             return strtoupper($matches[0][1]);
40         }, $vars['name']);
41
42         $vars['name'] = ucfirst($vars['vendor']) . ucfirst($camelCasedName);
43
44         return $vars;
45     }
46
47     /**
48      * Changes the name to a underscore separated name
49      * @param  array $vars
50      * @return array
51      */
52     private function correctThemeName($vars)
53     {
54         $vars['name'] = str_replace('-', '_', $vars['name']);
55
56         return $vars;
57     }
58 }