magento-hackathon/magento-composer-installer — pull request #72 by pspiller (2014-01-31 01:32:17+00:00)
Title: Add ability to translate path mapping prefixes

This pull request adds the ability to specify a set of translations that are applied to the path mappings magento-composer-installer uses to symlink extension files. This is useful if some types of extension files need to be linked into non-standard locations.

We maintain a Magento fork called Mercator (https://github.com/mercator). One change we made in Mercator was to put web-accessible files (CSS, JS, images) under a 'public' directory. This can then be used as the web server's document root, preventing accidentally exposing private files (i.e. local.xml).

This change to the file structure means that extensions that include public files need to be handled correctly. We use Composer to manage the extensions included in Mercator, so one option would have been to rewrite the modman files/composer.json map sections/etc for all of them. However, this required making backwards-incompatible changes and made it harder to add extensions. Instead, we modified magento-composer-installer to allow specifying a set of transformations. These are applied to each path mapping, and allow us to have web-accessible files automatically moved into the public directory. This allows extensions to be installed without changing their path mapping information. We thought this functionality might be useful to anybody running a similarly-modified version of Magento.

For example, the set of path mappings we specify in Mercator's composer.json are:

```json
"extra": {
"path-mapping-translations": {
"js/": "public/js/",
"media/": "public/media/",
"skin/": "public/skin/"
}
}
```

A partial example of a modman file used by one of the included extensions:

```
app/code/community/BL/CustomGrid/ app/code/community/BL/CustomGrid/
app/etc/modules/BL_CustomGrid.xml app/etc/modules/BL_CustomGrid.xml
app/locale/fr_FR/BL_CustomGrid.csv app/locale/fr_FR/BL_CustomGrid.csv
js/bl/customgrid/ js/bl/customgrid/
skin/adminhtml/default/default/bl/customgrid/ skin/adminhtml/default/default/bl/customgrid/
```

With the above path mappings in place, when this modman file is processed it will be interpreted as:

```
app/code/community/BL/CustomGrid/ app/code/community/BL/CustomGrid/
app/etc/modules/BL_CustomGrid.xml app/etc/modules/BL_CustomGrid.xml
app/locale/fr_FR/BL_CustomGrid.csv app/locale/fr_FR/BL_CustomGrid.csv
js/bl/customgrid/ public/js/bl/customgrid/
skin/adminhtml/default/default/bl/customgrid/ public/skin/adminhtml/default/default/bl/customgrid/
```

The 'skin' and 'js' files will be linked into place under the public directory, while everything that wasn't translated will be linked as normal.