Creates a new Address entity.

@param Request $request The request

@return array|RedirectResponse

@Route("/new")
@Template("EcommerceBundle:Address:new.html.twig")
429419
public function newAction(Request $request, $actorId)
    {
        $em = $this->getDoctrine()->getManager();
        /** @var Newsletter $entity */
        $entity = $em->getRepository('CoreBundle:Actor')->find($actorId);
        
        $address = new Address();
        $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage')));
       
        if($request->getMethod() == 'POST'){
            $form->handleRequest($request);
            if ($form->isSubmitted() && $form->isValid()) {
                    $address->setActor($entity);
                    $forBilling = $em->getRepository('EcommerceBundle:Address')->findOneBy(array('actor' => $entity, 'forBilling' => true));
                    if(!$forBilling) {
                        $address->setForBilling(true);
                    }else{
                        $address->setForBilling(false);
                    }
                    $em->persist($address);
                    $em->flush();
                    //if come from popup
                    if ($request->isXMLHttpRequest()) {         
                        return new JsonResponse(array(
                                    'id' => $address->getId()
                                ));
                    }
                    $this->get('session')->getFlashBag()->add('success', 'user.email.created');
                    return $this->redirect($this->generateUrl('core_actor_show', array('id' => $entity->getId())));
            }
            //if come from popup
            if ($request->isXMLHttpRequest()) {         
                return new JsonResponse(array(
                            'status' => false
                        ));
            }
        }

        return array(
            'entity' => $entity,
            'form'   => $form->createView(),
        );
    }
947600
public function moveAction(Request $request): Response
    {
        $form = $this->formFactory->moveLocation(
            new LocationMoveData()
        );
        $form->handleRequest($request);

        $location = $form->getData()->getLocation();

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (LocationMoveData $data) {
                $location = $data->getLocation();
                $newParentLocation = $data->getNewParentLocation();

                if (!$newParentLocation->getContent()->getContentType()->isContainer) {
                    throw new InvalidArgumentException(
                        '$newParentLocation',
                        'Cannot move location to a parent that is not a container'
                    );
                }

                $this->locationService->moveSubtree($location, $newParentLocation);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("'%name%' moved to '%location%'") */
                        'location.move.success',
                        ['%name%' => $location->getContentInfo()->name, '%location%' => $newParentLocation->getContentInfo()->name],
                        'location'
                    )
                );

                return new RedirectResponse($this->generateUrl('_ezpublishLocation', [
                    'locationId' => $location->id,
                ]));
            });

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

        return $this->redirect($this->generateUrl('_ezpublishLocation', [
            'locationId' => $location->id,
        ]));
    }
337299
public function newAction(Request $request)
    {
        $page = new Page();

        $form = $this->createCreateForm($page);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $channel = $this->getSelectedChannel();

            $page->setChannel($channel);

            $dm = $this->getDocumentManager();

            $dm->persist($page);
            $dm->flush();

            $this->get('integrated_page.services.route_cache')->clear();

            $this->get('braincrafted_bootstrap.flash')->success('Page created');

            return $this->redirect($this->generateUrl('integrated_page_page_index', ['channel' => $channel->getId()]));
        }

        return [
            'form' => $form->createView(),
        ];
    }
450546
public function createAction(Request $request)
    {
        $stocklevel = new StockLevel();
        $form = $this->createForm(new StockLevelType(), $stocklevel);
        if ($form->handleRequest($request)->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($stocklevel);
            $em->flush();

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

        return array(
            'stocklevel' => $stocklevel,
            'form'   => $form->createView(),
        );
    }
640168
public function createAddress(Request $request, SalesChannelContext $context): Response
    {
        $this->denyAccessUnlessLoggedIn();

        $page = $this->addressPageLoader->load($request, $context);

        return $this->renderStorefront('@Storefront/page/account/addressbook/create.html.twig', ['page' => $page]);
    }
784719
public function createAction(Request $request)
    {
        $this->denyAccessUnlessGranted('ROLE_ADMIN');

        $locale = new Locale();

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

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

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

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

        return $this->render('OpiferCmsBundle:Backend/Locale:create.html.twig', [
            'locale' => $locale,
            'form' => $form->createView()
        ]);
    }
405741
public function newAction(Request $request)
    {
        $acl = $this->get('bacon_acl.service.authorization');

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

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

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

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

        $form = $this->createForm(ModuleFormType::class, new Module());

        $form->handleRequest($request);

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

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

        return [
            '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(),
        ));
    }
71887
public function createAction(Request $request) {
        $entity = new Post();
        $form = $this->createCreateForm($entity);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $this->processVideo($entity);
            $em->persist($entity);
            $em->flush();

            return $this->redirect($this->generateUrl('admin_post_show', array('id' => $entity->getId())));
        } else {
            $this->get('session')->getFlashBag()->add(
                    'warning', $this->get('translator')->trans('save_fail')
            );
        }

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
1232350
public static function createFromBase(SymfonyRequest $request)
    {
        if ($request instanceof static) {
            return $request;
        }

        $content = $request->content;

        $newRequest = (new static)->duplicate(
            $request->query->all(), $request->request->all(), $request->attributes->all(),
            $request->cookies->all(), $request->files->all(), $request->server->all()
        );

        $newRequest->headers->replace($request->headers->all());

        $newRequest->content = $content;

        $newRequest->request = $newRequest->getInputSource();

        return $newRequest;
    }
1302840
public function createAction(Request $request)
    {
        $form = $this->container->get('form.factory')->createNamed(
            'page',
            CreationType::class,
            null,
            array(
                'action' => $this->container->get('router')->generate('synapse_admin_page_creation'),
                'method' => 'POST',
                'csrf_protection' => false,
            )
        );

        if ($request->request->has('page')) {
            $form->handleRequest($request);
            if ($form->isValid()) {
                $page = $form->getData()->resolve();

                return $this->redirect(
                    $this->container->get('router')->generate('synapse_admin_page_edition', array(
                        'id' => $page->getId(),
                    ))
                );
            }
        }

        return $this->render('SynapsePageBundle:Admin/Page:create.html.twig', array(
            '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,
            )
        );
    }
415231
public function createAction(Request $request)
    {
        $entity = new MessageType();
        $form = $this->createCreateForm($entity);
        $form->handleRequest($request);
        $data = $form->getData();
        if (!$data->getParent() && !isset($request->request->get($form->getName())['create_group'])) {
            throw new \InvalidArgumentException('You must either check "This is a new group" to verify that you want a new group or choose a group in the drop down.');
        }

        if ($form->isValid()) {
            $em = $this->getDoctrineManager();
            $em->persist($entity);
            $em->flush();
            return $this->redirectToRoute('messagetype_show', array('id' => $entity->getId()));
        }

        return $this->render(
            'BisonLabSakonninBundle:MessageType:edit.html.twig', array(
            'entity' => $entity,
            'form'   => $form->createView(),
        ));
    }
661412
public function newAction(Request $request)
    {
        
        $em = $this->getDoctrine()->getManager();
        $formConfig = array();
        $user = $this->container->get('security.token_storage')->getToken()->getUser();  
        if ($user->isGranted('ROLE_USER')) { 
            $formConfig['actor'] = $user; 
            //disable notification
            $admin = $em->getRepository('CoreBundle:Actor')->find(1);//admin
            $notificationManager = $this->container->get('notification_manager');
            $notificationManager->disableNotificationByDetail(
                    $admin, //admin
                    $user,//current user
                    'add_product', 
                    '"actor":'.$user->getId().'}'
                );
        }
        $entity = new Product();
        $form = $this->createForm('EcommerceBundle\Form\ProductType', $entity, $formConfig);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em->persist($entity);
            $em->flush();
            
            if($entity->getActor() instanceof Actor){
                //send emails to admin and actor
                $this->get('core.mailer')->sendActorNewProduct($entity);
            }
            $this->get('session')->getFlashBag()->add('success', 'product.created');

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

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
727596
public function createAction(Request $request)
        {

            $oRemoteApp = new RemoteApp();
            $form       = $this->createCreateForm($oRemoteApp);
            $form->handleRequest($request);

            if ($form->isValid()) {

                $sDomain = $oRemoteApp->getDomain();
                if(substr($sDomain,-1,1) !== "/"){
                    $sDomain .= "/";
                    $oRemoteApp->setDomain($sDomain);
                }

                $sModulePath = $oRemoteApp->getApiUrl();
                if(substr($sModulePath,0,1) === "/"){
                    $sModulePath = substr($sModulePath,1);
                    $oRemoteApp->setApiUrl($sModulePath);
                }

                $oRemoteApp->save();

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

            return $this->render('SlashworksAppBundle:RemoteApp:new.html.twig', array(
                'entity' => $oRemoteApp,
                'form'   => $form->createView(),
            ));
        }
173170
public function newAction(Request $request)
    {
        $entity = new Episode();
        $form   = $this->createCreateForm($entity);

        return [
            'entity' => $entity,
            'form'   => $form->createView(),
        ];
    }
866743
public function createAction(Request $request)
    {
        $form = $this->getForm();

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

                $this->getManager()->create($form->getData());
                $this->get('session')->getFlashBag()->add('success', 'Repository created successfully');

                return new RedirectResponse($this->generateUrl('snide_travinizer_dashboard'));
            } else {
                $this->get('session')->getFlashBag()->add('error', 'Some errors have been found');

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