Controller/TemplateController.php
public function getAction(Request $request)
    {
        $structureProvider = $this->get('sulu.content.structure_manager');
        $type = $request->get('type', 'default');

        $templates = [];
        foreach ($structureProvider->getStructures('article') as $structure) {
            if ($this->getType($structure->getStructure()) !== $type) {
                continue;
            }

            $templates[] = [
                'internal' => $structure->getInternal(),
                'template' => $structure->getKey(),
                'title' => $structure->getLocalizedTitle($this->getUser()->getLocale()),
            ];
        }

        return new JsonResponse(
            [
                '_embedded' => $templates,
                'total' => count($templates),
            ]
        );
    }
public function getAction(Request $request)
    {
        $structureProvider = $this->get('sulu.content.structure_manager');
        $type = $request->get('type', 'default');

        $templates = [];
        foreach ($structureProvider->getStructures('article') as $structure) {
            if ($this->getType($structure->getStructure()) !== $type) {
                continue;
            }

            $templates[] = [
                'internal' => $structure->getInternal(),
                'template' => $structure->getKey(),
                'title' => $structure->getLocalizedTitle($this->getUser()->getLocale()),
            ];
        }

        return new JsonResponse(
            [
                '_embedded' => $templates,
                'total' => count($templates),
            ]
        );
    }
public function getAction ( Request $ request ) { $ structureProvider = $ this -> get ( 'sulu.content.structure_manager' ) ; $ type = $ request -> get ( 'type' , 'default' ) ; $ templates = [ ] ; foreach ( $ structureProvider -> getStructures ( 'article' ) as $ structure ) { if ( $ this -> getType ( $ structure -> getStructure ( ) ) !== $ type ) { continue ; } $ templates [ ] = [ 'internal' => $ structure -> getInternal ( ) , 'template' => $ structure -> getKey ( ) , 'title' => $ structure -> getLocalizedTitle ( $ this -> getUser ( ) -> getLocale ( ) ) , ] ; } return new JsonResponse ( [ '_embedded' => $ templates , 'total' => count ( $ templates ) , ] ) ; }
Returns template for given article type.

@param Request $request

@return JsonResponse
Returns template for given article type .