New address action.

@param Request $request

@return \Symfony\Component\HttpFoundation\Response
961028
public function newAction(Request $request)
    {
        $user = $this->getUser();
        $repository = $this->get('ekyna_user.address.repository');

        $address = $repository->createNew();
        $address->setUser($user);

        $cancelPath = $this->generateUrl('ekyna_user_address_list');

        /** @var \Symfony\Component\Form\FormInterface $form */
        $form = $this
            ->createForm('ekyna_user_address', $address, [
                '_redirect_enabled' => 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' => $cancelPath,
                            ],
                        ],
                    ],
                ],
            ])
        ;

        $form->handleRequest($request);
        if ($form->isValid()) {
            $event = $this->get('ekyna_user.address.operator')->create($address);
            if (!$event->isPropagationStopped()) {
                $this->addFlash('ekyna_user.address.message.create.success', 'success');
                if (null !== $redirectPath = $form->get('_redirect')->getData()) {
                    return $this->redirect($redirectPath);
                }
                return $this->redirect($cancelPath);
            }
            $this->addFlash('ekyna_user.address.message.create.failure', 'danger');
        }

        return $this->render('EkynaUserBundle:Address:new.html.twig', [
            'form' => $form->createView()
        ]);
    }
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(),
        ));
    }
908103
public function newAction(Request $request)
    {
        $acl = $this->get('bacon_acl.service.authorization');

        if (!$acl->authorize('module-actions', 'NEW')) {
            throw $this->createAccessDeniedException();
        }

        $entityName         =   $this->getParameter('bacon_acl.entities.module_actions');
        $formTypeName       =   $this->getParameter('bacon_acl.forms.module_actions_form_type_class');
        $formHandlerName    =   $this->getParameter('bacon_acl.forms.module_actions_form_handler_class');

        $breadcumbs = $this->container->get('bacon_breadcrumbs');

        $breadcumbs->addItem([
            'title' => 'ModuleActions',
            'route' => 'module_actions',
        ]);

        $breadcumbs->addItem([
            'title' => 'New',
            'route' => '',
        ]);

        $form = $this->createForm($formTypeName, new $entityName());

        $form->add('add_all_actions', CheckboxType::class, [
            'required'  => false,
            'label'     => 'Adicionar em todas as actions',
            'mapped'    => false
        ]);

        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $handler = new $formHandlerName(
                $form,
                $this->getDoctrine()->getManager(),
                $this->get('session')->getFlashBag()
            );

            $handler->setRequest($request);

            if ($handler->save()) {
                return $this->redirect($this->generateUrl('module_actions'));
            }
        }

        return [
            'form'   => $form->createView(),
        ];
    }
202925
public function createURLAlias(Request $request)
    {
        $urlAliasCreate = $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type')),
                $request->getContent()
            )
        );

        if ($urlAliasCreate['_type'] === 'LOCATION') {
            $locationPathParts = explode(
                '/',
                $this->requestParser->parseHref($urlAliasCreate['location']['_href'], 'locationPath')
            );

            $location = $this->locationService->loadLocation(
                array_pop($locationPathParts)
            );

            try {
                $createdURLAlias = $this->urlAliasService->createUrlAlias(
                    $location,
                    $urlAliasCreate['path'],
                    $urlAliasCreate['languageCode'],
                    $urlAliasCreate['forward'],
                    $urlAliasCreate['alwaysAvailable']
                );
            } catch (InvalidArgumentException $e) {
                throw new ForbiddenException($e->getMessage());
            }
        } else {
            try {
                $createdURLAlias = $this->urlAliasService->createGlobalUrlAlias(
                    $urlAliasCreate['resource'],
                    $urlAliasCreate['path'],
                    $urlAliasCreate['languageCode'],
                    $urlAliasCreate['forward'],
                    $urlAliasCreate['alwaysAvailable']
                );
            } catch (InvalidArgumentException $e) {
                throw new ForbiddenException($e->getMessage());
            }
        }

        return new Values\CreatedURLAlias(
            array(
                'urlAlias' => $createdURLAlias,
            )
        );
    }
1125241
public function doAction(Request $request)
    {
        $token = $this->payum->getHttpRequestVerifier()->verify($request);

        $gateway = $this->payum->getGateway($token->getGatewayName());

        $gateway->execute(new Notify($token));

        return new Response('', 204);
    }
916355
public function addAction(Request $request)
    {
        $cm = new CronManager();
        $cron = new Cron();
        $this->addFlashFromCronManager($cm);
        $form = $this->createCronForm($cron);

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $cm->add($cron);
            $this->addFlashFromCronManager($cm);

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

        return $this->render('@BCCCronManager:Default:index.html.twig', array(
            'crons' => $cm->get(),
            'raw'   => $cm->getRaw(),
            'form'  => $form->createView(),
        ));
    }
831814
public function create_new($request)
    {
        if (!$this->canCreate()) {
            return $this->httpError(403, "You do not have permission to create new " . $this->getPluralName());
        }
        $this->addCrumb('Create new ' . $this->getSingularName());
        return $this->customise(['Form' => $this->CreationForm()]);
    }
656882
public function register(Request $request)
    {
        // Preventing spamer registration
        if ($request->input('account_intent')) {
            return redirect()->route('home');
        }

        $this->validator->setData($request->all());
        $input = $this->validator->validate('register');
        $user  = dispatch_now(new CreateUser($input));
        event(new Registered($user));

        $this->guard()->login($user);

        dispatch(new SendWelcomeEmail($user));
        session()->put('showWelcomePage', true);

        return redirect(routeMl('account.welcome', $this->getEffectiveLocale()));
    }
734296
public function changeAction(Request $request)
    {
        $regionManager = $this->get('compo_region.manager.region');

        $currentRegion = $request->request->get('current_region', $regionManager->getCurrentRegion());

        $regionManager->setCurrentRegion($currentRegion);

        return new JsonResponse($currentRegion);
    }
833222
public function newAction(Request $request)
    {
        $menu = new MenuItem();
        $form = $this->createForm('CoreExtraBundle\Form\MenuItemType', $menu, array('uploadDir'=> 'uploads/images/menu'));
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            
            //clean image form
            $this->get('core_manager')->cleanImageForm($request->files->get('menu_item'), $menu);
            
            $em = $this->getDoctrine()->getManager();
            $em->persist($menu);
            $em->flush();
            
            //images
            $image = $form->getNormData()->getImage();
            if ($image instanceof Image) {
                $this->get('core_manager')->uploadMenuImage($menu);
            }
            
            $this->get('session')->getFlashBag()->add('success', 'menu.created');

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

        return array(
            'entity' => $menu,
            '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()
        ]);
    }
1116058
public function indexAction(Request $request)
    {
        $hosts = $this->getParameter('jantao_dev_sitemap.hosts');
        $webDir = rtrim($this->getParameter('jantao_dev_sitemap.web_dir'), '/');
        if (!empty($hosts)) {
            $host = $request->getHttpHost();
            if (strpos($host, ':') !== false) {
                $host = substr($host, 0, strpos($host, ':'));
            }
            if (in_array($host, $hosts) && file_exists("$webDir/robots.$host.txt")) {
                return new BinaryFileResponse("$webDir/robots.$host.txt");
            }
        }
        if (file_exists("$webDir/robots.txt")) {
            return new BinaryFileResponse("$webDir/robots.txt");
        } else {
            throw $this->createNotFoundException('robots.txt not found');
        }
    }
1194726
public function phpAction(Request $request)
    {
        $show = $request->query->get('show', -1);

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

        return new Response($output);
    }
561625
public function createAction(Request $request)
    {
        $title = $request->get('title');

        $filterManager = $this->get('phlexible_message.filter_manager');

        $filter = $filterManager->create();
        $filter
            ->setUserId($this->getUser()->getId())
            ->setTitle($title)
            ->setModifiedAt(new \DateTime())
            ->setCreatedAt(new \DateTime());

        $filterManager->updateFilter($filter);

        return new ResultResponse(true, 'Filter created.');
    }
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(),
        );
    }
1002934
public function addAction(Request $request)
    {
        $storage = new Storage();

        /* @var $form Form */
        $form = $this->createForm(new StorageForm(), $storage);

        if ($request->getMethod() == 'POST') {
            $form->handleRequest($request);
            if ($form->isValid()) {
                $em = $this->getDoctrine()->getManager();
                $em->persist($storage);
                $em->flush();

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

        return $this->render('AnimeDbCatalogBundle:Storage:add.html.twig', [
            'form' => $form->createView(),
            'guide' => $this->get('anime_db.api.client')->getSiteUrl(self::GUIDE_LINK),
        ]);
    }
435241
public function createAction(Request $request)
    {
        $warehouse = new Warehouse();
        $form = $this->createForm(WarehouseType::class, $warehouse);
        if ($form->handleRequest($request)->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($warehouse);
            $em->flush();

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

        return array(
            'warehouse' => $warehouse,
            'form' => $form->createView(),
        );
    }