3 /* vim: set expandtab sw=4 ts=4 sts=4 ft=php: */
5 declare(strict_types
=1);
7 if (! defined('ROOT_PATH')) {
8 define('ROOT_PATH', dirname(__DIR__
) . DIRECTORY_SEPARATOR
);
11 $tmpDir = ROOT_PATH
. 'twig-templates';
13 /* Read replacements file */
14 $replacements = json_decode(file_get_contents($tmpDir . '/replace.json'), true);
17 $filesList = file_get_contents($tmpDir . '/filesList');
19 $options = getopt('', ['reverse::']);
21 foreach ($replacements as $templateName => $data) {
22 if (isset($options['reverse'])) {
23 $filesList = str_replace($data[0], $templateName, $filesList);
25 $filesList = str_replace($templateName, $data[0], $filesList);
29 /* Write back files list */
30 file_put_contents($tmpDir . '/filesList', $filesList);