@param Request $request

@Config\Route("/new", name="open_orchestra_group_new")
@Config\Method({"GET", "POST"})

@return Response
760647
public function newAction(Request $request)
    {
        $groupClass = $this->getParameter('open_orchestra_user.document.group.class');
        /** @var GroupInterface $group */
        $group = new $groupClass();
        $siteId = $this->get('open_orchestra_backoffice.context_backoffice_manager')->getSiteId();
        $group->setSite($this->get('open_orchestra_model.repository.site')->findOneBySiteId($siteId));

        $this->denyAccessUnlessGranted(ContributionActionInterface::CREATE, $group);

        $form = $this->createForm('oo_group', $group, array(
            'action'   => $this->generateUrl('open_orchestra_group_new'),
            'creation' => true,
            'method'   => 'POST'
        ));

        $form->handleRequest($request);

        if ($form->isValid()) {
            $documentManager = $this->get('object_manager');
            $documentManager->persist($group);
            $documentManager->flush();
            $message = $this->get('translator')->trans('open_orchestra_group.form.group.new.success');
            $this->get('session')->getFlashBag()->add('success', $message);

            $this->dispatchEvent(GroupEvents::GROUP_CREATE, new GroupEvent($group));
            $response = new Response(
                '',
                Response::HTTP_CREATED,
                array('Content-type' => 'text/plain; charset=utf-8', 'groupId' => $group->getId(), 'name' => $group->getName())
            );

            return $response;
        }

        return $this->renderAdminForm($form);
    }
212358
public function deleteNodeVersionsAction(Request $request)
    {
        $format = $request->get('_format', 'json');

        $facade = $this->get('jms_serializer')->deserialize(
            $request->getContent(),
            $this->getParameter('open_orchestra_api.facade.node_collection.class'),
            $format
        );
        $nodes = $this->get('open_orchestra_api.transformer_manager')->reverseTransform('node_collection', $facade);

        $nodeRepository = $this->get('open_orchestra_model.repository.node');
        $nodeIds = array();
        foreach ($nodes as $node) {
            if ($this->isGranted(ContributionActionInterface::DELETE, $node) &&
                $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(NodeStrategy::DELETE_VERSION, $node)
            ) {
                $this->get('open_orchestra_backoffice.manager.node')->deleteBlockInNode($node);
                $nodeIds[] = $node->getId();
                $this->dispatchEvent(NodeEvents::NODE_DELETE_VERSION, new NodeEvent($node));
            }
        }
        if (!empty($nodeIds)) {
            $nodeRepository->removeNodeVersions($nodeIds);
            $this->get('object_manager')->flush();
        }

        return array();
    }
439006
public function targetGroupAction(Request $request)
    {
        $currentTargetGroup = null;
        if ($request->headers->has($this->targetGroupHeader)) {
            $currentTargetGroup = $this->targetGroupRepository->find($request->headers->get($this->targetGroupHeader));
        }

        $targetGroup = $this->targetGroupEvaluator->evaluate(
            $currentTargetGroup ? TargetGroupRuleInterface::FREQUENCY_SESSION : TargetGroupRuleInterface::FREQUENCY_VISITOR,
            $currentTargetGroup
        );

        $response = new Response(null, 200, [
            $this->targetGroupHeader => $targetGroup ? $targetGroup->getId() : 0,
        ]);

        return $response;
    }
244194
public function listTableAction(Request $request)
    {
        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, StatusInterface::ENTITY_TYPE);
        $mapping = array(
            'label' => 'labels'
        );
        $configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);
        $repository = $this->get('open_orchestra_model.repository.status');
        $collection = $repository->findForPaginate($configuration);
        $recordsTotal = $repository->countNotOutOfWorkflow();
        $recordsFiltered = $repository->countWithFilter($configuration);
        $facade = $this->get('open_orchestra_api.transformer_manager')->transform('status_collection', $collection);
        $facade->recordsTotal = $recordsTotal;
        $facade->recordsFiltered = $recordsFiltered;

        return $facade;
    }
1294799
public function newAction(Request $request)
    {
        $role = new Role();
        $form = $this->createForm('CoreBundle\Form\RoleType', $role);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($role);
            $em->flush($role);

            //if come from popup
            if ($request->isXMLHttpRequest()) {         
                return new JsonResponse(array(
                            'id' => $role->getId(), 
                        ));
            }
            $this->get('session')->getFlashBag()->add('success', 'role.created');
            
            return $this->redirectToRoute('core_role_show', array('id' => $role->getId()));
        }

        return array(
            'role' => $role,
            'form' => $form->createView(),
        );
    }
899428
public function duplicateAction(Request $request)
    {
        $format = $request->get('_format', 'json');
        $facade = $this->get('jms_serializer')->deserialize(
            $request->getContent(),
            $this->getParameter('open_orchestra_api.facade.content.class'),
            $format
        );
        $content = $this->get('open_orchestra_api.transformer_manager')->reverseTransform('content', $facade);
        $this->denyAccessUnlessGranted(ContributionActionInterface::CREATE, $content);

        if (!$this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::READ, $content)) {
            throw new ContentTypeNotAllowedException();
        }

        $frontLanguages = $this->getParameter('open_orchestra_backoffice.orchestra_choice.front_language');

        $contentId = $content->getContentId();
        $newContentId = null;
        $objectManager = $this->get('object_manager');

        foreach (array_keys($frontLanguages) as $language) {
            $content = $this->findOneContent($contentId, $language);
            if ($content instanceof ContentInterface) {
                $duplicateContent = $this->get('open_orchestra_backoffice.manager.content')->duplicateContent($content, $newContentId);
                $objectManager->persist($duplicateContent);

                $newContentId = $duplicateContent->getContentId();
                $this->dispatchEvent(ContentEvents::CONTENT_DUPLICATE, new ContentEvent($duplicateContent));
            }
        }
        $objectManager->flush();

        return array();
    }
803267
public function indexAction(Request $request)
    {
        /** @var ConfigManager $configManager */
        $configManager = $this->get('opifer.cms.config_manager');

        $form = $this->createForm(ConfigType::class, []);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $config = [];
            foreach ($form->getData() as $group => $configuration) {
                foreach ($configuration as $key => $value) {
                    $config[$key] = $value;
                }
            }

            $em = $this->getDoctrine()->getManager();
            foreach ($config as $key => $value) {
                $item = $configManager->findOrCreate($key);
                $item->setValue($value);
                $em->persist($item);
            }

            $em->flush();

            $this->addFlash('success', 'flash.config_saved');

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

        return $this->render('OpiferCmsBundle:Backend/Config:index.html.twig', [
            'form' => $form->createView(),
        ]);
    }
740371
public function showAction(Request $request)
    {
        $gridSource = $this->get('dtc_grid.manager.source')->get($request->get('id'));
        $id = $request->get('identifier');
        $result = $gridSource->find($id);

        $responseResult = [];
        if (!$result) {
            return new Response('Not Found', 404);
        }
        if (is_array($result)) {
            foreach ($result as $key => $value) {
                $responseResult[$this->fromCamelCase($key)] = $value;
            }
        } elseif (method_exists($gridSource, 'getClassMetadata')) {
            $classMetadata = $gridSource->getClassMetadata();
            $fieldNames = $classMetadata->getFieldNames();
            foreach ($fieldNames as $fieldName) {
                $method = 'get'.ucfirst($fieldName);
                if (method_exists($result, $method)) {
                    $responseResult[$this->fromCamelCase($fieldName)] = $result->$method();
                }
            }
        }

        return new JsonResponse($responseResult);
    }
198582
public function deleteContentsAction(Request $request)
    {
        $format = $request->get('_format', 'json');
        $facade = $this->get('jms_serializer')->deserialize(
            $request->getContent(),
            $this->getParameter('open_orchestra_api.facade.content_collection.class'),
            $format
        );
        $contents = $this->get('open_orchestra_api.transformer_manager')->reverseTransform('content_collection', $facade);
        $repository = $this->get('open_orchestra_model.repository.content');

        foreach ($contents as $content) {
            $this->denyAccessUnlessGranted(ContributionActionInterface::DELETE, $content);
            $contentId = $content->getContentId();
            if (
                $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $content) &&
                $this->isGranted(ContributionActionInterface::DELETE, $content)
            ) {
                $repository->softDeleteContent($contentId);
                $this->dispatchEvent(ContentEvents::CONTENT_DELETE, new ContentDeleteEvent($contentId, $content->getSiteId()));
            }
        }

        return array();
    }
223101
public function updateAction(Request $request, ObjectStateGroup $group): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('state', 'administrate'));
        $form = $this->formFactory->updateObjectStateGroup(
            new ObjectStateGroupUpdateData($group)
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (ObjectStateGroupUpdateData $data) {
                $group = $data->getObjectStateGroup();
                $updateStruct = $this->objectStateService->newObjectStateGroupUpdateStruct();
                $updateStruct->identifier = $data->getIdentifier();
                $updateStruct->names[$group->mainLanguageCode] = $data->getName();

                $updatedGroup = $this->objectStateService->updateObjectStateGroup($group, $updateStruct);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Object state group '%name%' updated.") */
                        'object_state_group.update.success',
                        ['%name%' => $updatedGroup->getName()],
                        'object_state'
                    )
                );

                return $this->redirectToRoute('ezplatform.object_state.group.view', [
                    'objectStateGroupId' => $group->id,
                ]);
            });

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

        return $this->render('@ezdesign/admin/object_state_group/edit.html.twig', [
            'object_state_group' => $group,
            'form' => $form->createView(),
        ]);
    }
696284
public function createAction(Request $request)
    {
        if ($this->get('session')->has('module')) {
            // get the last module from the session to fill some defaults for the new one
            $tmpModule = $this->get('session')->get('module');

            // setup a fresh module object
            $module = new Module();
            $module->setStyle($tmpModule->getStyle());
        }
        else {
            // setup a fresh module object
            $module = new Module();

            // fill it with some defaults
            $module->setStyle('less');
        }

        // create form
        $form = $this->createForm(new ModuleType(), $module);

        if ($request->getMethod() == 'POST') {
            $form->bindRequest($request);

            if ($form->isValid()) {
                // set default templates
                $module->addTemplate(strtolower($module->getName()));

                // save the module in the session
                $this->get('session')->set('module', $module);

                // create the module in the filesystem
                try {
                    $moduleManager = $this->get('terrific.composer.module.manager');
                    $moduleManager->createModule($module);

                    $this->get('session')->setFlash('notice', 'Module ' . ucfirst($module->getName()) . ' created successfully');
                }
                catch (\Exception $e) {
                    $logger = $this->get('logger');
                    $logger->err($e->getMessage());

                    $this->get('session')->setFlash('notice', 'Module could not be created: ' . $e->getMessage());
                }

                if ($request->get('addskin', false)) {
                    // redirect to the add skin form
                    return $this->redirect($this->generateUrl('composer_add_skin'));
                }
                else {
                    // redirect to the create module form
                    return $this->redirect($this->generateUrl('composer_create_module'));
                }
            }
        }

        return array('form' => $form->createView());
    }
926838
public function addAction(Request $request): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('state', 'administrate'));
        $defaultLanguageCode = reset($this->languages);

        $form = $this->formFactory->createObjectStateGroup(
            new ObjectStateGroupCreateData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form,
                function (ObjectStateGroupCreateData $data) use ($defaultLanguageCode) {
                    $createStruct = $this->objectStateService->newObjectStateGroupCreateStruct(
                        $data->getIdentifier()
                    );
                    $createStruct->defaultLanguageCode = $defaultLanguageCode;
                    $createStruct->names = [$defaultLanguageCode => $data->getName()];
                    $group = $this->objectStateService->createObjectStateGroup($createStruct);

                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("Object state group '%name%' created.") */
                            'object_state_group.create.success',
                            ['%name%' => $data->getName()],
                            'object_state'
                        )
                    );

                    return $this->redirectToRoute('ezplatform.object_state.group.view', [
                        'objectStateGroupId' => $group->id,
                    ]);
                });

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

        return $this->render('@ezdesign/admin/object_state_group/add.html.twig', [
            'form' => $form->createView(),
        ]);
    }
1373633
public function createAction(Request $request)
    {
        $name = $request->get('name', 'new_set');

        $metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');

        if ($metaSetManager->findOneByName($name)) {
            return new ResultResponse(false, 'Name already in use.');
        }

        $metaSet = $metaSetManager->createMetaSet();
        $metaSet
            ->setId(UuidUtil::generate())
            ->setName($name)
            ->setCreateUser($this->getUser()->getDisplayName())
            ->setCreatedAt(new \DateTime())
            ->setModifyUser($this->getUser()->getDisplayName())
            ->setModifiedAt(new \DateTime());

        $metaSetManager->updateMetaSet($metaSet);

        return new ResultResponse(true, "Meta Set {$metaSet->getName()} created.");
    }
615210
public function newAction(Request $request)
    {
        $workflowFunctionClass = $this->getParameter('open_orchestra_workflow_function.document.workflow_function.class');
        $workflowFunction = new $workflowFunctionClass();

        $url = $this->generateUrl('open_orchestra_backoffice_workflow_function_new');
        $message = $this->get('translator')->trans('open_orchestra_workflow_function_admin.form.workflow_function.success');

        $form = $this->generateForm($workflowFunction, $url);
        $form->handleRequest($request);

        if ($this->handleForm($form, $message, $workflowFunction)) {
            $url = $this->generateUrl('open_orchestra_backoffice_workflow_function_form', array('workflowFunctionId' => $workflowFunction->getId()));
            $this->dispatchEvent(WorkflowFunctionEvents::WORKFLOWFUNCTION_CREATE, new WorkflowFunctionEvent($workflowFunction));

            return $this->redirect($url);
        }

        return $this->renderAdminForm($form);
    }
1194726
public function phpAction(Request $request)
    {
        $show = $request->query->get('show', -1);

        ob_start();
        phpinfo($show);
        $output = ob_get_clean();

        return new Response($output);
    }
845166
public function newAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $template = new Template();
        $form = $this->container->get('form.factory')->create(TemplateType::class, $template);

        $form->handleRequest($request);
        if ($form->isValid()) {
            $em->persist($template);
            $em->flush();

            return new JsonResponse([
                'success' => true,
                'url'     => $this->generateUrl('victoire_template_show', ['id' => $template->getId()]),
            ]);
        }

        return new JsonResponse(
            [
                'success' => true,
                'html'    => $this->container->get('templating')->render(
                    'VictoireTemplateBundle:Template:new.html.twig',
                    ['form' => $form->createView()]
                ),
            ]
        );
    }
1003458
public function listAction(Request $request)
    {
        $query = $this->addOrganizationFilter($request->query->all());

        return new JsonResponse($this->finder->search(
            $this->getClass(),
            $query,
            []
        ));
    }