Redirects to editor to edit the new template

@param \Illuminate\Http\Request $request
@param integer $template

@return \Illuminate\Http\RedirectResponse
185268
public function edit(Request $request, $template)
    {
        $data = $this->getData();

        /**
         * Set workspace identifier
         */
        \PDFGeneratorAPI::setWorkspace($this->userRepository->getWorkspaceIdentifier(Auth::user()));

        return redirect()->away(\PDFGeneratorAPI::editor($template, $data));
    }
136725
public function crudCreateObject(Request $request, array $templateVars = array())
    {
        if (!$this->crudCreateIsGranted()) {
            throw new AccessDeniedException('You need the permission to create an object!');
        }

        $object = $this->crudCreateFactory();
        $form = $this->crudForm($this->crudCreateFormType($object), $object);

        if ('POST' === $request->getMethod()) {
            $form->handleRequest($request);
            if ($this->crudCreateIsSubmitted($form)) {
                if ($form->isValid()) {
                    $this->crudCreatePrePersist($object);

                    $em = $this->crudManagerForClass($this->crudObjectClass());
                    $em->persist($object);
                    $em->flush();

                    $this->crudCreatePostFlush($object);

                    $this->crudFlashMessage($request, 'success', sprintf('%s.create.flash.success', $this->crudTransPrefix()));

                    return new RedirectResponse($this->crudCreateRedirectUrl($object), 302);
                } else {
                    $this->crudFlashMessage($request, 'error', sprintf('%s.create.flash.error', $this->crudTransPrefix()));
                }
            }
        }

        $baseTemplateVars = array(
            'request' => $request,
            'object' => $object,
            'form' => $form->createView(),
            'createRoute' => $this->crudCreateRoute(),
            'listRoute' => $this->crudListRoute(),
            'editRoute' => $this->crudEditRoute(),
            'viewRoute' => $this->crudViewRoute(),
            'deleteRoute' => $this->crudDeleteRoute(),
            'listRole' => $this->crudListRole(),
            'createRole' => $this->crudCreateRole(),
            'editRole' => $this->crudEditRole(),
            'viewRole' => $this->crudViewRole(),
            'deleteRole' => $this->crudDeleteRole(),
            'identifier' => $this->crudIdentifier(),
            'transPrefix' => $this->crudTransPrefix(),
            'objectClass' => $this->crudObjectClass(),
        );

        return $this->crudRender(
            $this->crudCreateTemplate(),
            array_replace_recursive($baseTemplateVars, $templateVars)
        );
    }
1271316
public function destroy(TemplateRequest $request, $template)
    {
        $template = $request->template;
        $path = theme_path('views').$template;

        // Block and notify if file does not exist.
        if (! \File::exists($path)) {
            return $this->makeRedirect(false, 'admin.templates.index', sprintf(
                __('msg.not_exists'), $template
            ));
        }

        // Block if file not delete.
        if (! \File::delete($path)) {
            return $this->makeRedirect(false, 'admin.templates.index', sprintf(
                __('msg.not_deleted'), $template
            ));
        }
        
        return $this->makeRedirect(true, 'admin.templates.index', sprintf(
            __('msg.deleted'), $template
        ));
    }
1340678
public function editAsCopy(Request $request, $template)
    {
        $name = $request->get('name');
        $data = $this->getData();

        try
        {
            /**
             * Set workspace identifier
             */
            \PDFGeneratorAPI::setWorkspace($this->userRepository->getWorkspaceIdentifier(Auth::user()));

            $newTemplate = \PDFGeneratorAPI::copy($template, $name);
        }
        catch(Exception $e)
        {
            return response()->json([
                'error' => $e->getMessage()
            ], $e->getCode());
        }

        return redirect()->away(\PDFGeneratorAPI::editor($newTemplate->id, $data));
    }
384154
public function editAction(Request $request)
    {
        $this->isGranted('EDIT');

        $this->container->get('ekyna_admin.menu.builder')
            ->breadcrumbAppend('settings', 'ekyna_setting.parameter.label.plural');

        $manager = $this->getSettingsManager();
        $schemas = $this->getSettingsRegistry()->getSchemas();

        $settings = [];
        $builder = $this
            ->createFormBuilder(null, [
                'data_class' => null,
                'admin_mode' => true,
                'cascade_validation' => true,
            ])
            ->add('actions', 'form_actions', [
                'buttons' => [
                    'save' => [
                        'type' => 'submit', 'options' => [
                            'button_class' => 'primary',
                            'label' => 'ekyna_core.button.save',
                            'attr' => [
                                'icon' => 'ok',
                            ],
                        ],
                    ],
                    'cancel' => [
                        'type' => 'button', 'options' => [
                            'label' => 'ekyna_core.button.cancel',
                            'button_class' => 'default',
                            'as_link' => true,
                            'attr' => [
                                'class' => 'form-cancel-btn',
                                'icon' => 'remove',
                                'href' => $this->generateUrl('ekyna_setting_parameter_admin_show'),
                            ],
                        ],
                    ],
                ],
            ])
        ;
        foreach($schemas as $namespace => $schema) {
            $builder->add($namespace, $schema);
            $settings[$namespace] = $manager->loadSettings($namespace);
        }

        $form = $builder
            ->getForm()
            ->setData($settings)
        ;

        if ($request->isMethod('POST') && $form->handleRequest($request)->isValid()) {
            $messageType = 'success';
            try {
                foreach($schemas as $namespace => $schema) {
                    $manager->saveSettings($namespace, $form->get($namespace)->getData());
                }
                $message = $this->getTranslator()->trans('ekyna_setting.parameter.flash.edit');
            } catch (ValidatorException $exception) {
                $message = $this->getTranslator()->trans($exception->getMessage(), [], 'validators');
                $messageType = 'danger';
            }
            $this->addFlash($message, $messageType);

            return $this->redirect($this->generateUrl('ekyna_setting_parameter_admin_show'));
        }

        return $this->render('EkynaSettingBundle:Settings:edit.html.twig', [
            'labels'     => $manager->getLabels(),
            'templates'  => $manager->getFormTemplates(),
            'form'       => $form->createView(),
        ]);
    }
806639
public function roleEditAction(Request $request, $id)
    {
        /** @var \Doctrine\ORM\EntityManager $em */
        $em = $this->getDoctrine()->getManager();

        $role = $em->find(Role::class, $id);

        $form = $this->createForm(RoleFormType::class, $role);

        if ($request->isMethod('POST')) {
            $form->handleRequest($request);
            if ($form->isValid()) {
                $this->persist($role, true);

                $this->addFlash('success', 'Роль обновлена.');

                return $this->redirect($this->generateUrl('cms_admin_user_roles'));
            }
        }

        return $this->render('@CMS/AdminUser/role_edit.html.twig', [
            'form' => $form->createView(),
        ]);
    }
99681
public function indexAction(Template $template)
    {
        $templating = $this->container->get('templating');

        $response = $this->getResponse(
            $templating->render(
                $template->getRenderName(),
                $template->getRenderData()
            )
        );

        return($response);
    }
77903
public function editAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();
        $site = $em->getRepository(Site::class)->find($id);

        $originalDomains = new ArrayCollection();
        foreach ($site->getDomains() as $domain) {
            $originalDomains->add($domain);
        }

        $form = $this->createForm(SiteType::class, $site);
        $form->handleRequest($request);


        if ($form->isSubmitted() && $form->isValid()) {

            // Remove deleted domains
            foreach ($originalDomains as $domain) {
                if (false === $site->getDomains()->contains($domain)) {
                    $em->remove($domain);
                }
            }

            // Add new domain
            foreach ($form->getData()->getDomains() as $domain) {
                $domain->setSite($site);
            }
            $em->persist($domain);

            $em->flush();

            return $this->redirectToRoute('opifer_cms_site_edit', ['id' => $site->getId()]);
        }

        return $this->render('OpiferCmsBundle:Backend/Site:edit.html.twig', [
            'form' => $form->createView(),
            'site' => $site,
        ]);
    }
1049589
public function editPermissionsAction(Request $request)
    {
        $context = $this->loadContext($request);

        /** @var \Ekyna\Bundle\UserBundle\Model\GroupInterface $resource */
        $resource = $context->getResource();

        $this->isGranted('EDIT', $resource);

        $cancelPath = $this->generateResourcePath($resource);

        $aclOperator = $this->get('ekyna_admin.acl_operator');
        $builder = $this->createFormBuilder(
            ['acls' => $aclOperator->generateGroupFormDatas($resource)],
            ['admin_mode' => true, '_redirect_enabled' => true]
        );
        $aclOperator->buildGroupForm($builder);

        $form = $builder->getForm();
        $form->add('actions', 'form_actions', [
            'buttons' => [
                'save' => [
                    'type' => 'submit', 'options' => [
                        'button_class' => 'primary',
                        'label' => 'ekyna_core.button.save',
                        'attr' => [
                            'icon' => 'ok',
                        ],
                    ],
                ],
                'cancel' => [
                    'type' => 'button', 'options' => [
                        'label' => 'ekyna_core.button.cancel',
                        'button_class' => 'default',
                        'as_link' => true,
                        'attr' => [
                            'class' => 'form-cancel-btn',
                            'icon' => 'remove',
                            'href' => $cancelPath,
                        ],
                    ],
                ],
            ],
        ]);

        $form->handleRequest($request);
        if ($form->isValid()) {
            try {
                $aclOperator->updateGroup($resource, $form->get('acls')->getData());

                $this->addFlash('Les permissions ont bien été modifiées.', 'success');

                if (null !== $redirectPath = $form->get('_redirect')->getData()) {
                    return $this->redirect($redirectPath);
                }

                return $this->redirect($cancelPath );
            } catch(\Exception $e) {
                $this->addFlash('Erreur lors de la mise à jour des permissions :<br>' . $e->getMessage(), 'danger');
            }
        }

        $this->appendBreadcrumb(
            sprintf('%s-edit-permissions', $this->config->getResourceName()),
            'ekyna_user.group.button.edit_permissions'
        );

        $datas = [
            'permissions' => $aclOperator->getPermissions(),
            'form' => $form->createView(),
        ];

        return $this->render(
            'EkynaUserBundle:Admin/Group:edit_permissions.html.twig',
            $context->getTemplateVars($datas)
        );
    }
83593
public function editAction(Request $request, int $urlId): Response
    {
        $url = $this->urlService->loadById($urlId);

        $form = $this->formFactory->createUrlEditForm(new URLUpdateData([
            'id' => $url->id,
            'url' => $url->url,
        ]));

        $form->handleRequest($request);
        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (URLUpdateData $data) use ($url) {
                $this->urlService->updateUrl($url, $data);
                $this->notificationHandler->success(
                    $this->translator->trans('url.update.success', [], 'linkmanager')
                );

                return $this->redirectToRoute('ezplatform.link_manager.list');
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->render('@ezdesign/link_manager/edit.html.twig', [
            'form' => $form->createView(),
            'url' => $url,
        ]);
    }
559881
public function createAction(Request $request)
    {
        $newTag = new Tag();
        $newTagForm = $this->createForm(new TagType(),$newTag);

        $newTagForm->handleRequest($request);

        if($newTagForm->isValid())
        {
            $em = $this->getDoctrine()->getManager();
            $em->persist($newTag);
            $em->flush();
        }

        return $this->redirect($this->generateUrl('tag'));
    }
542782
public function postTemplate(Page $page, Template $template)
    {
        $this->authorize('editTemplate', $page);

        $page->setTemplate($template);

        Event::fire(new Events\PageTemplateWasChanged($page, $template));

        return $page->getCurrentVersion()->getStatus();
    }
935235
public function editAction(Request $request): Response
    {
        /* @todo it shouldn't rely on keys from request */
        $requestKeys = $request->request->keys();
        $formName = reset($requestKeys) ?: null;

        $form = $this->formFactory->contentEdit(null, $formName);
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (ContentEditData $data) {
                $contentInfo = $data->getContentInfo();
                $versionInfo = $data->getVersionInfo();
                $language = $data->getLanguage();
                $versionNo = $versionInfo->versionNo;
                $location = $data->getLocation();

                $content = $this->contentService->loadContent($contentInfo->id);
                if ((new ContentIsUser($this->userService))->isSatisfiedBy($content)) {
                    return $this->redirectToRoute('ez_user_update', [
                        'contentId' => $contentInfo->id,
                        'versionNo' => $versionNo,
                        'language' => $language->languageCode,
                    ]);
                }

                if (!$versionInfo->isDraft()) {
                    $contentDraft = $this->contentService->createContentDraft($contentInfo, $versionInfo);
                    $this->updateDraftInitialLanguage($contentDraft, $language);
                    $versionNo = $contentDraft->getVersionInfo()->versionNo;

                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("New Version Draft for '%name%' created.") */
                            'content.create_draft.success',
                            ['%name%' => $contentInfo->name],
                            'content'
                        )
                    );
                }

                return $this->redirectToRoute('ez_content_draft_edit', [
                    'contentId' => $contentInfo->id,
                    'versionNo' => $versionNo,
                    'language' => $language->languageCode,
                    'locationId' => null !== $location
                        ? $location->id
                        : $contentInfo->mainLocationId,
                ]);
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        /** @var ContentEditData $data */
        $data = $form->getData();
        $contentInfo = $data->getContentInfo();

        if (null !== $contentInfo) {
            return $this->redirectToRoute('_ezpublishLocation', [
                'locationId' => $contentInfo->mainLocationId,
            ]);
        }

        return $this->redirectToRoute('ezplatform.dashboard');
    }
242483
public function render($template)
    {
        $this->setTemplate($template);
        extract($this->data);
        ob_start();
        require $this->templatePath;

        return ob_get_clean();
    }
300182
public function update(Request $request){

        $contents = $this->content->update($request->all());

        alert()->success('Bloc édité');

        return redirect('build/campagne/'.$contents->newsletter_campagne_id.'#componant');
    }
579902
public function webPreViewAction(Request $request, $template, $format = null)
    {
        if ('txt' !== $format) {
            $format = 'html';
        }

        $template = urldecode($template);

        $locale = $request->getLocale();

        // merge request vars with dummyVars, but make sure request vars remain as they are.
        $emailVars = array_merge(array(), $request->query->all());
        $emailVars = $this->get('azine_email_web_view_service')->getDummyVarsFor($template, $locale, $emailVars);
        $emailVars = array_merge($emailVars, $request->query->all());

        // add the styles
        $emailVars = $this->getTemplateProviderService()->addTemplateVariablesFor($template, $emailVars);

        // add the from-email for the footer-text
        if (!array_key_exists('fromEmail', $emailVars)) {
            $noReply = $this->getParameter('azine_email_no_reply');
            $emailVars['fromEmail'] = $noReply['email'];
            $emailVars['fromName'] = $noReply['name'];
        }

        // set the emailLocale for the templates
        $emailVars['emailLocale'] = $locale;

        // replace absolute image-paths with relative ones.
        $emailVars = $this->getTemplateProviderService()->makeImagePathsWebRelative($emailVars, $locale);

        // add code-snippets
        $emailVars = $this->getTemplateProviderService()->addTemplateSnippetsWithImagesFor($template, $emailVars, $locale);

        // render & return email
        $response = $this->renderResponse("$template.$format.twig", $emailVars);

        // add campaign tracking params
        $campaignParams = $this->getTemplateProviderService()->getCampaignParamsFor($template, $emailVars);
        $campaignParams['utm_medium'] = 'webPreview';
        if (sizeof($campaignParams) > 0) {
            $htmlBody = $response->getContent();
            $htmlBody = $this->get('azine.email.bundle.twig.filters')->addCampaignParamsToAllUrls($htmlBody, $campaignParams);

            $emailOpenTrackingCodeBuilder = $this->get('azine_email_email_open_tracking_code_builder');
            if ($emailOpenTrackingCodeBuilder) {
                // add an image at the end of the html tag with the tracking-params to track email-opens
                $imgTrackingCode = $emailOpenTrackingCodeBuilder->getTrackingImgCode($template, $campaignParams, $emailVars, 'dummy', 'dummy@from.email.com', null, null);
                if ($imgTrackingCode && strlen($imgTrackingCode) > 0) {
                    // replace the tracking url, so no request is made to the real tracking system.
                    $imgTrackingCode = str_replace('://', '://webview-dummy-domain.', $imgTrackingCode);
                    $htmlCloseTagPosition = strpos($htmlBody, '</html>');
                    $htmlBody = substr_replace($htmlBody, $imgTrackingCode, $htmlCloseTagPosition, 0);
                }
            }
            $response->setContent($htmlBody);
        }

        // if the requested format is txt, remove the html-part
        if ('txt' == $format) {
            // set the correct content-type
            $response->headers->set('Content-Type', 'text/plain');

            // cut away the html-part
            $content = $response->getContent();
            $textEnd = stripos($content, '<!doctype');
            $response->setContent(substr($content, 0, $textEnd));
        }

        return $response;
    }
73817
public function setTemplate($template)
    {
        if (is_string($template)) {
            $template = new TemplateView($template);
        }
        $template->mergeData([
            'layout' => $this
        ]);
        $this->addChild(new Part($template, 'template'));
        return $this;
    }