get('kernel')->getRootDir(); $d = realpath($d.'/../public/'.$path); if(!is_dir($d)) return $this->container->get('net15.restifier.dispatch')->error('translation folder is missing'); $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($d)); $files = array(); foreach ($rii as $file) { if ($file->isDir()){ continue; } $f = str_replace($d.'/','',$file->getPathname()); $f = str_replace('/'.$file->getFilename(),'',$f); $files[$f][] = str_replace('.json','',$file->getFilename()); } return new JsonResponse(['path' => $path, 'format' => '.json', 'templates' => $files]); } }