@EXT\Route("/internationalization/submit", name="claro_admin_i18n_submit")

@param Request $request
@return \Symfony\Component\HttpFoundation\Response
176682
public function submitAction()
    {
        $localeManager = $this->container->get('claroline.common.locale_manager');
        $availableLocales = $localeManager->getImplementedLocales();
        $activatedLocales = $localeManager->retrieveAvailableLocales();
        $form = $this->createForm(new InternationalizationType($activatedLocales, $availableLocales));
        $form->handleRequest($this->get('request'));

        if ($form->isValid()) {
            $data = $form->get('locales')->getData();
            $this->container->get('claroline.config.platform_config_handler')->setParameter('locales', $data);

            return new RedirectResponse($this->get('router')->generate('claro_admin_parameters_index'));
        }

       return $this->render(
           'ClarolineCoreBundle:Administration:Internationalization\form.html.twig',
           array('form' => $form->createView(), 'product' => $product)
       );
    }
898391
private function save(Request $request, FormInterface $form, CrudConfigurator $crudConfigurator)
    {
        $translator = $this->get('translator');
        $translationDomain = $this->getParameter('symfonyid.admin.translation_domain');

        $form->handleRequest($request);
        if (!$form->isValid()) {
            return $this->handleView(new View(array(
                'status' => false,
                'message' => $translator->trans('message.form_not_valid', array(), $translationDomain),
            )));
        }

        $reflectionModel = new \ReflectionClass($crudConfigurator->getCrud()->getModelClass());
        /** @var \SymfonyId\AdminBundle\Annotation\Driver $driver */
        $driver = $this->get('symfonyid.admin.manager.driver_finder')->findDriverForClass($reflectionModel->getName());
        /** @var \SymfonyId\AdminBundle\Crud\CrudOperationHandler $crudOperationHandler */
        $crudOperationHandler = $this->get('symfonyid.admin.crud.crud_operation_handler');

        $model = $form->getData();
        if (!$crudOperationHandler->save($driver, $model)) {
            return $this->handleView(new View(array(
                'status' => false,
                'message' => $translator->trans($crudOperationHandler->getErrorMessage(), array(), $translationDomain),
            )));
        }

        return $this->createResponse($model);
    }
688612
public function editAction(Request $request, $id = null)
    {
        $this->denyAccessUnlessGranted('ROLE_ADMIN');

        $em = $this->getDoctrine()->getManager();

        if (is_numeric($id)) {
            $locale = $em->getRepository(Locale::class)->find($id);
        } else {
            $locale = $em->getRepository(Locale::class)->findOneByLocale($id);
        }

        $form = $this->createForm(new LocaleType(), $locale);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em->persist($locale);
            $em->flush();

            $this->addFlash('success', 'Locale has been updated successfully');

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

        return $this->render('OpiferCmsBundle:Backend/Locale:edit.html.twig', [
            'locale' => $locale,
            'form' => $form->createView()
        ]);
    }
416424
public function postAction(Request $request)
    {
        $action = $request->get('action');
        $document = $this->getDocumentManager()->create(self::DOCUMENT_TYPE);
        $locale = $this->getRequestParameter($request, 'locale', true);
        $data = $request->request->all();

        $this->persistDocument($data, $document, $locale);
        $this->handleActionParameter($action, $document, $locale);
        $this->getDocumentManager()->flush();

        return $this->handleView(
            $this->view($document)->setSerializationContext(
                SerializationContext::create()
                    ->setSerializeNull(true)
                    ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage'])
            )
        );
    }
878373
private function getLocale(Request $request)
    {
        $uri = $request->getRequestUri();

        foreach ($this->locales as $locale) {
            if (false !== strpos($uri, '/'.$locale.'/')) {
                return $locale;
            }
        }

        return $this->defaultLocale;
    }
26656
public function determineLocale(Request $request)
    {
        return $request->session()->get($this->sessionKey, $this->fallback);
    }
1181174
public function regionIndexAction(Request $request)
    {
        $engineRegion = $this->get('cms.region');

        $region = $engineRegion->create();
        $region->setUser($this->getUser());

        $form = $engineRegion->createForm($region);

        if ($request->isMethod('POST')) {
            $form->handleRequest($request);
            if ($form->isValid()) {
                $engineRegion->update($form->getData());
                $this->addFlash('success', 'Область создана.');

                return $this->redirectToRoute('cms_admin_structure_region');
            }
        }

        return $this->render('CMSBundle:AdminStructure:region_index.html.twig', [
            'all_regions' => $engineRegion->all(),
            'form'        => $form->createView(),
        ]);
    }
509253
public static function setLangAttribute($request)
    {
        // language may be present in url without {param} defined
        $languageSlug= self::setFromURL($request);
        if(!$languageSlug) {
            $languageSlug = App::getLocale();
        }

        //add lang parameter to every route/action request if user is accessing a language that's different than default
        if(config('project.multilanguage')) {
            // hide slug on default language in frontend
            //backend
            if (!isInAdmin()) {
                if (config('project.hideDefaultLanguageInURL') && $languageSlug ==  Language::getDefault('slug')) {
                    $languageSlug = '';
                }
            }

            URL::defaults(['lang' => $languageSlug]);
        }

        return;
    }
1168614
private function getTranslatedUrl(Request $request)
    {
        /** @var Route $route */
        $route = $request->route();

        if ( ! ($route instanceof Route) || is_null($route->getName()))
            return null;

        return $this->translateRoute($route->getName(), $route->parameters());
    }
1184639
public function uploadFileAction(Request $request)
    {
        /** @var FormBuilderInterface $uploadForm */
        $form = $this->createForm(TranslationsFileUploadType::class);
        $configurator = $this->getAdminListConfigurator();

        if (Request::METHOD_POST === $request->getMethod()) {
            $form->handleRequest($request);
            if ($form->isSubmitted() && $form->isValid()) {
                $locales = $this->getParameter('kuma_translator.managed_locales');
                $data = $form->getData();
                $file = $data['file'];
                $force = $data['force'];
                $imported = $this->container->get('kunstmaan_translator.service.importer.importer')->importFromSpreadsheet($file, $locales, $force);
                $this->addFlash(FlashTypes::SUCCESS, sprintf('Translation imported: %d', $imported));
            }
        }

        return [
            'form' => $form->createView(),
            'adminlistconfigurator' => $configurator,
        ];
    }
688871
private function getLanguage(Request $request)
    {
        $locale = $this->getRequestParameter($request, 'locale', false, null);

        if ($locale) {
            return $locale;
        }

        return $this->getRequestParameter($request, 'language', true);
    }
436617
public function nodesFormAction(Request $request)
    {
        $node = new Node();
        // Manage edition mode
        $this->currentNode = $request->get('node');
        if ($this->currentNode) {
            $node = $this->get("ydle.node.manager")->find($request->get('node'));
        }
        $action = $this->get('router')->generate('submitNodeForm', array('node' => $this->currentNode));

        $form = $this->createForm("node_form", $node);
        $form->handleRequest($request);

        return $this->render('YdleHubBundle:Nodes:form.html.twig', array(
            'action' => $action,
            'entry' => $node,
            'form' => $form->createView()
        ));
    }
357220
protected function _initTranslation(\Mmi\Http\Request $request)
    {
        //języki nie zdefiniowane
        if (empty(\App\Registry::$config->languages)) {
            return;
        }
        //niepoprawny język
        if ($request->__get('lang') && !in_array($request->__get('lang'), \App\Registry::$config->languages)) {
            throw new \Mmi\Mvc\MvcNotFoundException('Language not found');
        }
        //ustawianie języka z requesta
        if ($request->__get('lang')) {
            return \App\Registry::$translate->setLocale($request->__get('lang'));
        }
        //ustawienie języka edycji
        $session = new \Mmi\Session\SessionSpace('cms-language');
        $lang = in_array($session->lang, \App\Registry::$config->languages) ? $session->lang : \App\Registry::$config->languages[0];
        \App\Registry::$translate->setLocale($lang);
    }
660574
public function updateMainTranslationAction(Request $request): Response
    {
        $form = $this->createForm(MainTranslationUpdateType::class, new MainTranslationUpdateData());
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (MainTranslationUpdateData $data) {
                $content = $data->getContent();
                $contentInfo = $content->contentInfo;
                $mapper = new MainTranslationUpdateMapper();
                $contentMetadataUpdateStruct = $mapper->reverseMap($data);
                $this->contentService->updateContentMetadata($contentInfo, $contentMetadataUpdateStruct);
                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Main language for '%name%' updated.") */
                        'content.main_language_update.success',
                        ['%name%' => $contentInfo->name],
                        'content'
                    )
                );

                return new RedirectResponse($this->generateUrl('_ezpublishLocation', [
                    'locationId' => $contentInfo->mainLocationId,
                    '_fragment' => 'ez-tab-location-view-translations',
                ]));
            });
            if ($result instanceof Response) {
                return $result;
            }
        }
        /** @var \EzSystems\EzPlatformAdminUi\Form\Data\Content\Translation\MainTranslationUpdateData $data */
        $data = $form->getData();
        $contentInfo = $data->getContentInfo();
        if (null !== $contentInfo) {
            return new RedirectResponse($this->generateUrl('_ezpublishLocation', [
                'locationId' => $contentInfo->mainLocationId,
                '_fragment' => 'ez-tab-location-view-translations',
            ]));
        }

        return $this->redirectToRoute('ezplatform.dashboard');
    }
230829
public function removeTranslationAction(Request $request): Response
    {
        $form = $this->contentTypeFormFactory->removeContentTypeTranslation(
            new TranslationRemoveData()
        );
        $form->handleRequest($request);

        /** @var TranslationRemoveData $data */
        $data = $form->getData();
        $contentType = $data->getContentType();
        $contentTypeGroup = $data->getContentTypeGroup();

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (TranslationRemoveData $data) {
                $contentType = $data->getContentType();
                $languageCodes = $data->getLanguageCodes();
                $contentTypeGroup = $data->getContentTypeGroup();
                try {
                    $contentTypeDraft = $this->tryToCreateContentTypeDraft($contentType);
                } catch (BadStateException $e) {
                    $userId = $contentType->modifierId;
                    $this->notificationHandler->error(
                        $this->translator->trans(
                            /** @Desc("Draft of the Content Type '%name%' already exists and is locked by '%userContentName%'") */
                            'content_type.edit.error.already_exists',
                            ['%name%' => $contentType->getName(), '%userContentName%' => $this->getUserNameById($userId)],
                            'content_type'
                        )
                    );

                    return $this->redirectToRoute('ezplatform.content_type.view', [
                        'contentTypeGroupId' => $contentTypeGroup->id,
                        'contentTypeId' => $contentType->id,
                    ]);
                }
                foreach ($languageCodes as $languageCode => $isChecked) {
                    $newContentTypeDraft = $this->contentTypeService->removeContentTypeTranslation($contentTypeDraft, $languageCode);
                }
                $this->contentTypeService->publishContentTypeDraft($newContentTypeDraft);

                return new RedirectResponse($this->generateUrl('ezplatform.content_type.view', [
                    'contentTypeId' => $contentType->id,
                    'contentTypeGroupId' => $contentTypeGroup->id,
                    '_fragment' => TranslationsTab::URI_FRAGMENT,
                ]));
            });

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

        return $this->redirectToRoute('ezplatform.content_type.view', [
            'contentTypeGroupId' => $contentTypeGroup->id,
            'contentTypeId' => $contentType->id,
        ]);
    }
204029
public function newAction(Request $request)
    {
        $sakonninTemplate = new Sakonnintemplate();
        $default_lang_code = $this->container->get('translator')->getLocale();
        $sakonninTemplate->setLangCode($default_lang_code);
        $form = $this->createForm('BisonLab\SakonninBundle\Form\SakonninTemplateType', $sakonninTemplate);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrineManager();
            $em->persist($sakonninTemplate);
            $em->flush();

            return $this->redirectToRoute('sakonnintemplate_show', array('id' => $sakonninTemplate->getId()));
        }

        return $this->render('BisonLabSakonninBundle:SakonninTemplate:new.html.twig',
            array(
            'sakonninTemplate' => $sakonninTemplate,
            'form' => $form->createView(),
        ));
    }
1075961
public function deleteAction(Request $request, $id)
    {

        $handler = new LanguageFormHandler(
            $this->createDeleteForm(),
            $request,
            $this->get('doctrine')->getManager(),
            $this->get('session')->getFlashBag()
        );


        $entity = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->find($id);

        if ($handler->delete($entity)) {
            return $this->redirect($this->generateUrl('admin_language'));
        }

        return $this->redirect($this->generateUrl('admin_language_show', array('id' => $id)));
    }