Create a new developer applications

@param  Request $request The current request
@return Response
965808
public function newApp(Request $request)
    {
        if ($request->request->get('type') === ApiApplication::DESKTOP_TYPE) {
            $form = new \API_OAuth2_Form_DevAppDesktop($request);
        } else {
            $form = new \API_OAuth2_Form_DevAppInternet($request);
        }

        $violations = $this->getValidator()->validate($form);

        if ($violations->count() === 0) {
            $user = $this->getAuthenticatedUser();
            $application = $this->getApiApplicationManipulator()
                ->create(
                    $form->getName(),
                    $form->getType(),
                    $form->getDescription(),
                    sprintf('%s%s', $form->getSchemeWebsite(), $form->getWebsite()),
                    $user,
                    sprintf('%s%s', $form->getSchemeCallback(), $form->getCallback())
                );

            // create an account as well
            $this->getApiAccountManipulator()->create($application, $user, V2::VERSION);

            return $this->app->redirectPath('developers_application', ['application' => $application->getId()]);
        }

        return $this->render('/developers/application_form.html.twig', [
            "violations" => $violations,
            "form"       => $form,
        ]);
    }
1289014
public function newAction(Request $request)
    {
        $entity = new Translation();
        $form = $this->createForm('CoreBundle\Form\TranslationType', $entity);
        
        $form->handleRequest($request);

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

            //Create entry in DB
            $this->updateTranslation($entity);
            
            $this->get('session')->getFlashBag()->add('success', 'translation.created');
            
            return $this->redirectToRoute('core_translation_index');
        }

        return $this->render('CoreBundle:Translation:new.html.twig', array(
            'translation' => $entity,
            'form' => $form->createView(),
        ));
    }
1010184
public function openNew(Request $request)
    {
        $data = $this->getData();

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

        return redirect()->away(\PDFGeneratorAPI::editor(null, $data));
    }
41895
public function install(Request $request)
    {
        $package = $request->get('package');
        $version = $request->get('version');
        try {
            $response = $this->manager()->requirePackage(
                [
                    'name'    => $package,
                    'version' => $version,
                ]
            );
        } catch (\Exception $e) {
            return $this->getJsonException($e);
        }

        if ($response === 0) {
            $this->app['extensions.stats']->recordInstall($package, $version);
            $this->app['logger.system']->info("Installed $package $version", ['event' => 'extensions']);

            return new Response($this->manager()->getOutput());
        }

        return $this->getJsonException(new PackageManagerException($this->manager()->getOutput(), $response));
    }
761743
public function newChildAction(Request $request)
    {
        $this->isGranted('CREATE');

        $context = $this->loadContext($request);

        $resourceName = $this->config->getResourceName();
        $resource = $context->getResource($resourceName);

        $child = $this->createNewFromParent($context, $resource);

        if (0 < strlen($referer = $request->headers->get('referer'))) {
            $cancelPath = $referer;
        } else {
            $cancelPath = $this->generateResourcePath($request);
        }

        $form = $this
            ->createForm($this->config->getFormType(), $child, [
                'action' => $this->generateUrl(
                    $this->config->getRoute('new_child'),
                    $context->getIdentifiers(true)
                ),
                'method' => 'POST',
                'attr' => [
                    'class' => 'form-horizontal form-with-tabs',
                ],
                'admin_mode' => true,
                '_redirect_enabled' => true,
            ])
            ->add('actions', 'form_actions', [
                'buttons' => [
                    'saveAndList' => [
                        'type' => 'submit', 'options' => [
                            'button_class' => 'primary',
                            'label' => 'ekyna_core.button.save_and_list',
                            'attr' => [
                                'icon' => 'list',
                            ],
                        ],
                    ],
                    '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($this->getRequest());
        if ($form->isValid()) {

            $this->getRepository()->persistAsLastChildOf($child, $resource);

            // TODO use ResourceManager
            $event = $this->getOperator()->create($child);

            /* if ($request->isXmlHttpRequest()) {
                if ($event->hasErrors()) {
                    $errorMessages = $event->getErrors();
                    $errors = [];
                    foreach ($errorMessages as $message) {
                        $errors[] = $message->getMessage();
                    }
                    return new JsonResponse(array('error' => implode(', ', $errors)));
                }

                return new JsonResponse(array(
                    'id' => $resource->getId(),
                    'name' => (string)$resource,
                ));
            }*/

            $event->toFlashes($this->getFlashBag());

            if (!$event->hasErrors()) {
                /** @noinspection PhpUndefinedMethodInspection */
                if ($form->get('actions')->get('saveAndList')->isClicked()) {
                    $redirectPath = $this->generateResourcePath($resource, 'list');
                } elseif (null === $redirectPath = $form->get('_redirect')->getData()) {
                    $redirectPath = $this->generateResourcePath($child);
                }
                return $this->redirect($redirectPath);
            }
        }

        return $this->render(
            $this->config->getTemplate('new_child.html'),
            $context->getTemplateVars([
                'child' => $child,
                'form' => $form->createView()
            ])
        );
    }
537635
public function createAction(Request $request)
    {
        $user = $this->getParameter('opifer_cms.user_model');
        $user = new $user();

        $form = $this->createForm(UserFormType::class, $user);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $this->get('fos_user.user_manager')->updateUser($user, true);

            $this->addFlash('success', $this->get('translator')->trans('user.new.success', [
                '%username%' => ucfirst($user->getUsername()),
                '%id%' => $user->getId(),
            ]));

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

        return $this->render('OpiferCmsBundle:Backend/User:create.html.twig', [
            'form' => $form->createView(),
        ]);
    }
727811
public function createAction(Request $request)
    {
        $entity = new User();
        $form = $this->createCreateForm($entity);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $userService = $this->get("flowcode.user");
            $userService->create($entity);

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

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
837157
public function createAction(Request $request)
    {
        $this->registerBreadcrubms()->addItem($this->get("translator")->trans("Add"));

        $entity = $this->getNewEntity();
        $form = $this->createCreateForm($entity);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();

            try {
                if ($form->get("saveAndPublish")->isClicked()) {
                    $entity->setPublished(1);
                }
            } catch (OutOfBoundsException $e) {

            }

            $em->persist($entity);

            $em->flush();

            $this->get('session')->getFlashBag()->add('notice', $this->getEntityName() . ' has been created!');

            if ($form->get("saveAndExit")->isClicked()) {
                return $this->redirect($this->generateUrl($this->getRouteName(), $this->getRouteParams()));
            } else {
                try {
                    if ($form->get("addNext")->isClicked()) {
                        return $this->redirect($this->generateUrl($this->getRouteName() . "Add", $this->getRouteParams()));
                    }
                } catch (OutOfBoundsException $e) {

                }
                return $this->redirect($this->generateUrl($this->getRouteName() . "Edit", $this->getRouteParams(['id' => $entity->getId()])));
            }
        }

        return $this->render($this->getListTemplate() . ":edit.html.twig", [
            'entity' => $entity,
            'form' => $form->createView()
        ]);
    }
1050815
public function newAction(Request $request)
    {
        $slider = new Slider();
        $form = $this->createForm('CoreExtraBundle\Form\SliderType', $slider,  array('uploadDir'=> 'uploads/images/slider' ));
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            
            //clean image form
            $this->get('core_manager')->cleanImageForm($request->files->get('slider'), $slider);
            
            $em->persist($slider);
            $em->flush();
            
            $this->get('session')->getFlashBag()->add('success', 'slider.created');

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

        return array(
            'entity' => $slider,
            'form' => $form->createView(),
        );
    }
4268
public function newAction(Request $request)
    {
        $this->denyAccessUnlessGranted(ContributionActionInterface::CREATE, UserInterface::ENTITY_TYPE);

        $userClass = $this->container->getParameter('open_orchestra_user.document.user.class');
        /** @var UserInterface $user */
        $user = new $userClass();
        $user->setEmail($request->get('email'));
        $user->setLastName($request->get('lastName'));
        $user->setFirstName($request->get('firstName'));

        $form = $this->createForm('oo_registration_user', $user, array(
                'action' => $this->generateUrl('open_orchestra_user_admin_new'),
                'required_password' => true,
                'validation_groups' => array('Registration'),
            )
        );

        $form->handleRequest($request);

        if ($form->isValid()) {
            $documentManager = $this->get('object_manager');
            $documentManager->persist($user);
            $documentManager->flush();
            $message = $this->get('translator')->trans('open_orchestra_user_admin.new.success');

            $this->dispatchEvent(UserEvents::USER_CREATE, new UserEvent($user));
            $response = new Response(
                $message,
                Response::HTTP_CREATED,
                array('Content-type' => 'text/plain; charset=utf-8', 'userId' => $user->getId())
            );

            return $response;
        }

        return $this->renderAdminForm($form);
    }
1319050
public function createAction(Request $request)
    {
        $contentTypeEntityClass = $this->configurationManager->getEntityClass('content_type');
        $contentType = new $contentTypeEntityClass;

        $form = $this->createForm(ContentTypeFormType::class, $contentType, [
            'action' => $this->generateUrl('sherlockode_acb_content_type_create'),
            'contentType' => $contentType,
        ]);

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->om->persist($contentType);
            $this->om->flush();

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

        return $this->render('@SherlockodeAdvancedContent/ContentType/create_content_type.html.twig', [
            'form' => $form->createView(),
            'data' => $contentType,
        ]);
    }
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()]
                ),
            ]
        );
    }
650695
public function createAction(Request $request)
    {
        $this->denyAccessUnlessGranted('ROLE_ADMIN');

        $domain = new Domain();

        $form = $this->createForm(DomainType::class, $domain);
        $form->handleRequest($request);

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

            $this->addFlash('success', 'Domaim has been created successfully');

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

        return $this->render('OpiferCmsBundle:Backend/Domain:create.html.twig', [
            'domain' => $domain,
            'form' => $form->createView()
        ]);
    }
150029
public function create(Request $request)
    {
        app('soda.interface')->setHeading('New Role');
        app('soda.interface')->breadcrumbs()->addLink(route('soda.roles.index'), 'Roles');

        try {
            $role = $this->roles->newInstance($request);
            $permissionIds = $this->roles->getPermissions();
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.create', ['object' => 'role']));
        }

        return soda_cms_view('data.roles.view', compact('role', 'permissionIds'));
    }
844988
public function createAction(Request $request)
    {
        $template = new Template();

        $form = $this->createForm(TemplateType::class, $template);
        $form->handleRequest($request);

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

            $em->persist($template);
            $em->flush();

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

        return $this->render('OpiferCmsBundle:Backend/Template:create.html.twig', [
            'form' => $form->createView(),
        ]);
    }
1006739
public function create(Request $request)
    {
        app('soda.interface')->setHeading('New User');
        app('soda.interface')->breadcrumbs()->addLink(route('soda.users.index'), 'Users');

        try {
            $user = $this->users->newInstance($request);
            $roleIds = $this->users->getRoles();
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.create', ['object' => 'user']));
        }

        return soda_cms_view('data.users.view', compact('user', 'roleIds'));
    }
881482
public function createAction(Request $request)
    {
        $review = $this->get('opifer.review.review_manager')->createClass();

        $form = $this->createForm(ReviewType::class, $review);
        $form->handleRequest($request);

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

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

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

        return $this->render($this->getParameter('opifer_review.review_create_view'), [
            'form' => $form->createView(),
        ]);
    }