Submit a request to the API.

@param Requestable $request
@return object
518393
public function submit(RequestableInterface $request)
    {
        $this->applyDefaultOptions($request);

        $url = $this->options['host'] . '/wkf/' . $this->options['connection'];
        $data = DynamicPacker::pack($request);

        return new DynamicResponse($this->browser->submit($url, $data));
    }
11158
protected function send(Request $request)
    {
        try {
            $response = $this->client->send($request);
        } catch (ClientException $e) {
            $response = $e->getResponse();
        } catch (ServerException $e) {
            $response = $e->getResponse();
        }

        return $response;
    }
875365
public function handle(Request $request)
    {
        try {
            $restRequest = new RestRequest($this->config, $request->getMethod(), $request->getUri(), $request->getContent());
            $restResponse = $this->adapter->processRequest($restRequest);
        } catch (\Exception $e) {
            if (true === $this->debugEnabled()) {
                throw $e;
            }
            $restResponse = $this->adapter->handleException($e);
        }
        return new Response($restResponse->getContent(), $restResponse->getStatus(), $restResponse->getHeaders());
    }
726318
public static function create_from_request($request) {
        if($type = $request->getVar('accept')) {
            try {
                if(array_key_exists($type, self::$lookup)) {
                    return self::create(self::$lookup[$type]);
                }
            } catch(\Exception $e) {}
        }
        $types = $request->getAcceptMimetypes();
        foreach($types as $type) {
            try {
                return self::create($type);
            } catch(RestUserException $e) {}
        }
        return self::create();
    }
441104
public function post(Request $request)
    {
        $userData = $this->getContentAsArray($request);

        $errors = $this->userRegistrationValidator->validate($userData ?: []);

        if (count($errors) > 0) {
            return $this->createConstraintViolationResponse($errors);
        }

        try {
            $newUser = $this->userService->register($userData);
        } catch (OutOfBoundsException $e) {
            return $this->createEmailNotUniqueResponse();
        }

        $newUser = $this->userArrayWithoutPassword($newUser);

        $newUser['_href'] = $this->url('user-entity', array('user' => $newUser['id']));

        return $this->createJsonResponse($newUser, 201);
    }
721541
public function createAction(Request $request)
    {
        $form = $this->buildForm();

        if ($request->isMethod('POST') && $this->submitForm($form, $request)->isValid()) {
            try {
                $this->getDomainManager()->create($form->getData());
            } catch (DomainException $e) {
                $this->processException($e);
            }
        }

        return $this->processAction('create', $form, Response::HTTP_CREATED);
    }
4967
public function newAction(Request $request)
    {
        $page = new Page();
        $form = $this->createForm('CoreBundle\Form\PageType', $page, array('translator'=>$this->get('translator')));
        $form->handleRequest($request);

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

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

        return array(
            'page' => $page,
            'form' => $form->createView(),
        );
    }
45797
public function postEdit(Request $request)
    {

        $form = FormBuilder::create(get_class($this->form), [
            'model' => $this->model
        ]);


        if ($form->hasError()) {
            return $form->validateAndRedirectBack();
        }

        $result = $this->beforeSave();

        if ($result != null) {
            return $result;
        }

        $result = $this->save($this->dataToSave($request), $request);


        if ($this->isTranslatableModel() && !$this->model->hasTranslation($this->model->getTable(), $this->model->getKey())) {
            $this->saveTranslation(app()->getLocale());
        }

        if ($result != null) {
            return $result;
        }

        return redirect()->to(action($this->getControllerNameForAction().'@getIndex'));

    }
933915
public function postAction(Request $request)
    {
        $document = $this->documentManager->create(Structure::TYPE_SNIPPET);
        $form = $this->processForm($request, $document);

        return $this->handleView($form->getData());
    }
736124
public function postAction(Request $request)
    {
        $type = 'page';
        $language = $this->getLanguage($request);
        $action = $request->get('action');

        $this->checkActionParameterSecurity($action, $language);

        $document = $this->getDocumentManager()->create($type);
        $formType = $this->getMetadataFactory()->getMetadataForAlias($type)->getFormType();

        $this->persistDocument($request, $formType, $document, $language);
        $this->handleActionParameter($action, $document, $language);
        $this->getDocumentManager()->flush();

        $context = new Context();
        $context->setGroups(['defaultPage']);

        return $this->handleView($this->view($document)->setContext($context));
    }
1358710
public function registerAction(Request $request): Response
    {
        $content = $request->getContent();
        $content = \json_decode($content, true);

        /** @var TenantInterface $tenant */
        /** @noinspection PhpUndefinedMethodInspection */
        $tenant = $this->em->getRepository($this->tenantClass)->findOneByClientKey($content['clientKey']);
        if ($tenant !== null) {
            try {
                $authorizationHeaderArray = \explode(' ', $request->headers->get('authorization'));
                if (\count($authorizationHeaderArray) <= 1) {
                    throw new \InvalidArgumentException('Bad authorization header');
                }

                $jwt = $authorizationHeaderArray[1];
                JWT::decode($jwt, $tenant->getSharedSecret(), ['HS256']);
            } catch (\Throwable $e) {
                $this->logger->error($e->getMessage(), ['exception' => $e]);

                return new Response('Unauthorized', 401);
            }
        } else {
            $tenantClass = $this->tenantClass;
            $tenant = new $tenantClass();
        }

        $tenant
            ->setAddonKey($content['key'])
            ->setClientKey($content['clientKey'])
            ->setPublicKey($content['publicKey'])
            ->setSharedSecret($content['sharedSecret'])
            ->setServerVersion($content['serverVersion'])
            ->setPluginsVersion($content['pluginsVersion'])
            ->setBaseUrl($content['baseUrl'])
            ->setProductType($content['productType'])
            ->setDescription($content['description'])
            ->setEventType($content['eventType'])
        ;

        if (\array_key_exists('oauthClientId', $content)) {
            $tenant->setOauthClientId($content['oauthClientId']);
        }

        $this->em->persist($tenant);
        $this->em->flush();

        return new Response('OK', 200);
    }
244684
protected function createHttpRequest($request)
    {
        return new Request(
            $request->get ?? [], $request->post ?? [], [], $request->cookie ?? [], $request->files ?? [],
            $this->parseRequestServer($request), $request->rawContent()
        );
    }
782269
public function send(Request $request)
    {
        $response   = new PutResponse();
        $rpbPutReq  = $this->createRpbMessage($request);
        $rpbPutResp = $this->client->send($rpbPutReq, RiakMessageCodes::DT_UPDATE_REQ, RiakMessageCodes::DT_UPDATE_RESP);

        if ( ! $rpbPutResp instanceof DtUpdateResp) {
            return $response;
        }

        if ($rpbPutResp->hasContext()) {
            $response->context = $rpbPutResp->context;
        }

        if ($rpbPutResp->hasCounterValue()) {
            $response->value = $rpbPutResp->counter_value;
            $response->type  = 'counter';
        }

        if ($rpbPutResp->hasSetValue()) {
            $response->value = $rpbPutResp->set_value;
            $response->type  = 'set';
        }

        if ($rpbPutResp->hasMapValue()) {
            $response->value = $this->opConverter->fromProtoBuf($rpbPutResp->map_value);
            $response->type  = 'map';
        }

        return $response;
    }
1094482
public function newAction(Request $request)
    {
        $visit = new Visit();
        $form = $this->createForm('CoreExtraBundle\Form\VisitType', $visit);
        $form->handleRequest($request);

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

            //if come from popup
            if ($request->isXMLHttpRequest()) {         
                return new JsonResponse(array(
                            'id' => $visit->getId(), 
                        ));
            }
            
            /*********************/
            /********Custom ******/
            /*********************/
            //truncate table email token
//            $connection = $em->getConnection();
//            $statement = $connection->prepare("TRUNCATE TABLE email_token");
//            $statement->execute();
            $email = $visit->getActor()->getEmail();
            $emailToken = new EmailToken();
            $emailToken->setEmail($email);
            $token = sha1(uniqid());
            $emailToken->setToken($token);
            $em->persist($emailToken);
            $visit->setEmailToken($emailToken);
            $em->flush();
            $template   = $this->get('twig')->loadTemplate('CoreExtraBundle:Email:email.template.html.twig');
            $body  = $template->renderBlock('body', array(
                'user_name' => $visit->getActor()->getFullName(),
                'place_name' => 'Place name'
            ));
            $body = preg_replace('/(#TOKEN#)/', $token, $body);  
            
            $this->get('core.mailer')->sendFeedback(array($email), $body, 'Place Name');
            $this->get('session')->getFlashBag()->add('success', 'visit.sent');

            $this->get('session')->getFlashBag()->add('success', 'visit.created');
            
            return $this->redirectToRoute('visit_show', array('id' => $visit->getId()));
        }

        return array(
            'visit' => $visit,
            'form' => $form->createView(),
        );
    }
954699
public function accept(Request $request)
    {
        if (! $request->has('token')) abort(404);
        if (! $invitation = $this->validateToken($request->input('token'))) abort(404);
        return $this->showAcceptUserInvitationForm($invitation);
    }
211225
public function run(Request $request) {
    // process the requested action
    ObjectFactory::getInstance('actionMapper')->processAction($request, $this->response);
    return $this->response;
  }
735778
public function handle(Request $request)
    {
        //get the correct method
        if ($this->method === 'GET') {
            $values = $request->query->all();
        } else {
            $values = $request->request->all();
        }

        // The form is submitted if at least one field is present
        if (count(array_intersect_key($values, $this->rows)) > 0) {
            return $this->submitForm($values);
        }
    }