mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +00:00
Fix template generator
This commit is contained in:
@@ -36,7 +36,15 @@ class module_console_systemTemplateGenerator extends Command
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$tplDir = __DIR__ . '/../../../../templates/';
|
||||
$tplDirs = array(
|
||||
realpath(__DIR__ . '/../../../../templates/web/'),
|
||||
realpath(__DIR__ . '/../../../../templates/mobile/')
|
||||
);
|
||||
|
||||
$n_ok = $n_error = 0;
|
||||
|
||||
foreach ($tplDirs as $tplDir)
|
||||
{
|
||||
$tmpDir = __DIR__ . '/../../../../tmp/cache_twig/';
|
||||
|
||||
$loader = new Twig_Loader_Filesystem($tplDir);
|
||||
@@ -45,6 +53,7 @@ class module_console_systemTemplateGenerator extends Command
|
||||
'cache' => $tmpDir,
|
||||
'auto_reload' => true
|
||||
));
|
||||
|
||||
$twig->addExtension(new Twig_Extensions_Extension_I18n());
|
||||
|
||||
/**
|
||||
@@ -83,18 +92,12 @@ class module_console_systemTemplateGenerator extends Command
|
||||
$twig->addFilter('geoname_name_from_id', new Twig_Filter_Function('geonames::name_from_id'));
|
||||
|
||||
|
||||
$n_ok = $n_error = 0;
|
||||
|
||||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tplDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file)
|
||||
$finder = new Symfony\Component\Finder\Finder();
|
||||
foreach ($finder->files()->in(array($tplDir)) as $file)
|
||||
{
|
||||
if (strpos($file, '/.svn/') !== false)
|
||||
continue;
|
||||
if (substr($file->getFilename(), 0, 1) === '.')
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
$twig->loadTemplate(str_replace($tplDir, '', $file));
|
||||
$twig->loadTemplate(str_replace($tplDir, '', $file->getPathname()));
|
||||
$output->writeln('' . $file . '');
|
||||
$n_ok ++;
|
||||
}
|
||||
@@ -104,6 +107,7 @@ class module_console_systemTemplateGenerator extends Command
|
||||
$n_error ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln("");
|
||||
$output->write(sprintf('%d templates generated. ', $n_ok));
|
||||
|
Reference in New Issue
Block a user