1: <?php
2:
3: namespace Mapbender\CoreBundle\Controller;
4:
5: use JMS\SecurityExtraBundle\Annotation\Secure;
6: use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7: use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8: use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
9: use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
10: use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
11: use Symfony\Component\Form\FormBuilder;
12: use Symfony\Component\DependencyInjection\ContainerInterface;
13: use Symfony\Component\Security\Core\SecurityContext;
14: use Symfony\Component\HttpFoundation\Request;
15: use Symfony\Component\HttpFoundation\Response;
16: use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
17: 18: 19: 20: 21: 22:
23: class TranslationController extends Controller {
24: 25: 26: 27:
28: public function transAction() {
29: $tr = $this->get('translator');
30: $request = $this->get('request');
31: $paramspost = $request->request->all();
32: $data = array();
33: foreach ($paramspost as $k => $v) {
34: $par_vals = explode("|", $v);
35: if(count($par_vals) == 1){
36: $data[$k] = $tr->trans($v);
37: } else if(count($par_vals) > 1){
38: if($par_vals[0]== "twig"){
39: $templating = $this->get("templating");
40: $content = $templating->render($par_vals[1],array());
41: $data[$k] = $content;
42: }
43: }
44: }
45: $response = new Response();
46: $response->setContent(json_encode($data));
47: $response->headers->set('Content-Type', 'application/json');
48: return $response;
49: }
50:
51: }
52: