public function createAction(Request $request)
    {
        $templateRepository = $this->get('phlexible_media_template.template_manager');

        $type = $request->get('type');
        $key = $request->get('key');

        switch ($type) {
            case 'image':
                $template = new ImageTemplate();
                $template->setCache(false);
                break;
            case 'video':
                $template = new VideoTemplate();
                $template->setCache(true);
                break;
            case 'audio':
                $template = new AudioTemplate();
                $template->setCache(true);
                break;
            default:
                throw new InvalidArgumentException("Unknown template type $type");
        }

        $template->setKey($key);

        $templateRepository->updateTemplate($template);

        return new ResultResponse(true, 'New "'.$type.'" template "'.$key.'" created.');
    }
public function createAction(Request $request)
    {
        $templateRepository = $this->get('phlexible_media_template.template_manager');

        $type = $request->get('type');
        $key = $request->get('key');

        switch ($type) {
            case 'image':
                $template = new ImageTemplate();
                $template->setCache(false);
                break;
            case 'video':
                $template = new VideoTemplate();
                $template->setCache(true);
                break;
            case 'audio':
                $template = new AudioTemplate();
                $template->setCache(true);
                break;
            default:
                throw new InvalidArgumentException("Unknown template type $type");
        }

        $template->setKey($key);

        $templateRepository->updateTemplate($template);

        return new ResultResponse(true, 'New "'.$type.'" template "'.$key.'" created.');
    }
public function createAction ( Request $ request ) { $ templateRepository = $ this -> get ( 'phlexible_media_template.template_manager' ) ; $ type = $ request -> get ( 'type' ) ; $ key = $ request -> get ( 'key' ) ; switch ( $ type ) { case 'image' : $ template = new ImageTemplate ( ) ; $ template -> setCache ( false ) ; break ; case 'video' : $ template = new VideoTemplate ( ) ; $ template -> setCache ( true ) ; break ; case 'audio' : $ template = new AudioTemplate ( ) ; $ template -> setCache ( true ) ; break ; default : throw new InvalidArgumentException ( "Unknown template type $type" ) ; } $ template -> setKey ( $ key ) ; $ templateRepository -> updateTemplate ( $ template ) ; return new ResultResponse ( true , 'New "' . $ type . '" template "' . $ key . '" created.' ) ; }
Create mediatemplate.

@param Request $request

@throws \InvalidArgumentException

@return ResultResponse
@Route("/create", name="mediatemplates_templates_create")
Create mediatemplate .