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]); } public function newLangFieldAction(Request $request){ $className = str_replace('~', '\\', $request->get('className')); $linguisticaId = $request->get('linguisticaId'); $linguistica = $this->get('net15.linguistica.translator')->getById((int)$linguisticaId, $className); return $this->render('@FormForge/FormForgeField/new.lang.field.html.twig',[ 'fieldValue'=>$linguistica, 'className'=>$request->get('className'), 'routAdd'=>'form_forge_add_lang_field' ]); } public function addLangFieldAction(Request $request){ $className = str_replace('~', '\\', $request->get('className')); $linguistica = $this->get('net15.linguistica.translator')->getById($request->get('linguisticaId'), $className); $languages = array(); $languages['fr'] = $request->get('value_fr'); $languages['en'] = $request->get('value_en'); $languages['es'] = $request->get('value_es'); $label = $this->get('net15.linguistica.translator')->addLinguisticaStrValue($linguistica, $languages); return new Response((string)$label); } }