1 | <?php |
||
12 | class PathTranslationParser implements Parser |
||
13 | { |
||
14 | /** |
||
15 | * @var array Variants on each prefix that path mappings are checked |
||
16 | * against. |
||
17 | */ |
||
18 | protected $pathPrefixVariants = array('', './'); |
||
19 | |||
20 | /** |
||
21 | * @var array Path mapping prefixes that need to be translated (i.e. to |
||
22 | * use a public directory as the web server root). |
||
23 | */ |
||
24 | protected $pathPrefixTranslations = array(); |
||
25 | |||
26 | /** |
||
27 | * @var Parser |
||
28 | */ |
||
29 | protected $parser; |
||
30 | |||
31 | /** |
||
32 | * Constructor. Sets the list of path translations to use. |
||
33 | * |
||
34 | * @param Parser $parser |
||
35 | * @param array $translations Path translations |
||
36 | */ |
||
37 | 2 | public function __construct(Parser $parser, array $translations) |
|
42 | |||
43 | /** |
||
44 | * Given an array of path mapping translations, combine them with a list |
||
45 | * of starting variations. This is so that a translation for 'js' will |
||
46 | * also match path mappings beginning with './js'. |
||
47 | * |
||
48 | * @param $translations |
||
49 | * @return array |
||
50 | */ |
||
51 | 2 | protected function createPrefixVariants($translations) |
|
62 | |||
63 | /** |
||
64 | * loop the mappings for the wrapped parser, check if any of the targets are for |
||
65 | * directories that have been moved under the public directory. If so, |
||
66 | * update the target paths to include 'public/'. As no standard Magento |
||
67 | * path mappings should ever start with 'public/', and path mappings |
||
68 | * that already include the public directory should always have |
||
69 | * js/skin/media paths starting with 'public/', it should be safe to call |
||
70 | * multiple times on either. |
||
71 | * |
||
72 | * @return array Updated path mappings |
||
73 | */ |
||
74 | 1 | public function getMappings() |
|
92 | } |
||
93 |