解析响应

@param $request
@param $messagePrefix
@return array
421861
protected function parseResponse($request, $messagePrefix){
        try{
            $response = $this->client->getAcsResponse($request);
            if(is_object($response)){
                $response = (array)$response;
            }
            if($response['Code'] === 'OK'){
                return $this->success($messagePrefix.'成功', $response);
            }else{
                return $this->error($response['Message'], $response);
            }
        }catch(\Exception $exception){
            return $this->error($messagePrefix.'失败', ['error' => $exception->getMessage()]);
        }
    }
1166299
private function parseAcceptLanguage(Request $request)
    {
        $locales = [];
        $acceptLanguage = trim($request->headers->get('Accept-Language'));

        if (!empty($acceptLanguage)) {
            $locales = array_map(function (AcceptLanguage $acceptLanguage) {
                return $acceptLanguage->getType();
            }, $this->localeNegotiator->parse($acceptLanguage));
        }

        return $locales;
    }
406042
public function prefill(Request $request)
    {
        // Determine the ContentTypes that we're doing the prefill for
        $choices = [];
        foreach ($this->getOption('contenttypes') as $key => $contentType) {
            $nameKey = 'contenttypes.' . $key . '.name.plural';
            $nameTrans = Trans::__($nameKey, [], 'contenttypes');
            $name = ($nameTrans === $nameKey) ? $contentType['name'] : $nameTrans;
            $choices[$name] = $key;
        }

        // Create the form
        $options = [
            'attr'         => ['data-bind' => '{"bind":"prefill"}'],
            'contenttypes' => $choices,
        ];
        $form = $this->createFormBuilder(PrefillType::class, [], $options)
            ->getForm()
        ;

        if ($request->isMethod('POST') || $request->query->getBoolean('force')) {
            $form->handleRequest($request);
            $contentTypeNames = (array) $form->get('contenttypes')->getData();

            // ✓ - If the DB is empty
            // ✓ - If ContentType(s) *are* selected
            // ✓ - If *no* ContentTypes are selected *and* a ContentType's record count < max
            // X - If *no* ContentTypes are selected *and* a ContentType's record count >= max
            $canExceedMax = true;
            if (count($contentTypeNames) === 0) {
                $contentTypeNames = $choices;
                $canExceedMax = false;
            }

            $builder = $this->app['prefill.builder'];
            $results = $builder->build($contentTypeNames, 5, $canExceedMax);
            $this->session()->set('prefill_result', $results);

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

        $prefillResult = $this->session()->remove('prefill_result') ?: ['created' => null, 'errors' => null, 'warnings' => null];
        $context = [
            'contenttypes' => $choices,
            'form'         => $form->createView(),
            'results'      => $prefillResult,
        ];

        return $this->render('@bolt/prefill/prefill.twig', $context);
    }
411811
private function getListRepresentation($request)
    {
        /** @var RestHelperInterface $restHelper */
        $restHelper = $this->get('sulu_core.doctrine_rest_helper');
        $locale = $this->getRequestParameter($request, 'locale', true);
        $fieldDescriptors = $this->getManager()->getListFieldDescriptors($locale);

        /** @var DoctrineListBuilderFactory $factory */
        $factory = $this->get('sulu_core.doctrine_list_builder_factory');
        $listBuilder = $factory->create(self::$entityName);
        $restHelper->initializeListBuilder(
            $listBuilder,
            $fieldDescriptors
        );

        if ($request->get('context')) {
            $listBuilder->where($fieldDescriptors['context'], $request->get('context'));
        }

        // return all filters created by the user or without user
        $userCondition = [$this->getUser()->getId(), null];
        $listBuilder->in($fieldDescriptors['user'], $userCondition);

        $list = new ListRepresentation(
            $listBuilder->execute(),
            self::$entityKey,
            'get_filters',
            $request->query->all(),
            $listBuilder->getCurrentPage(),
            $listBuilder->getLimit(),
            $listBuilder->count()
        );

        return $list;
    }
451780
protected function getSessionMessage(&$messageType = null)
    {
        $session = $this->getRequest()->getSession();
        $message = $session->get('Security.Message.message');
        $messageType = null;
        if (empty($message)) {
            return null;
        }

        $messageType = $session->get('Security.Message.type');
        $messageCast = $session->get('Security.Message.cast');
        if ($messageCast !== ValidationResult::CAST_HTML) {
            $message = Convert::raw2xml($message);
        }

        return sprintf('<p class="message %s">%s</p>', Convert::raw2att($messageType), $message);
    }
822242
public function verifyReturn($request)
    {
        if(empty($request)) {//判断POST来的数组是否为空
            return false;
        }

        //生成签名结果
        $data['prestr'] = Helper::buildRequestPreStr($request);
        $data['sign'] = $request['sign'];
        $isSign = $this->sign->verifySign($data, trim($this->config[$this->signKeyConfigName]));
        //获取支付宝远程服务器ATN结果（验证是否是支付宝发来的消息）
        $responseTxt = 'false';
        if (! empty($request["notify_id"])) {
            $responseTxt = $this->getResponse($request["notify_id"]);
        }

        if (preg_match("/true$/i",$responseTxt) and $isSign) {
            return true;
        }

        return false;
    }
635656
public function getBrowserAcceptLanguages(Request $request)
    {
        $browserLanguages = [];

        if (strlen($request->server->get('HTTP_ACCEPT_LANGUAGE')) == 0) {
            return [];
        }

        $languages = $this->splitHttpAcceptHeader(
            $request->server->get('HTTP_ACCEPT_LANGUAGE')
        );
        foreach ($languages as $lang) {
            if (strstr($lang, '-')) {
                $codes = explode('-', $lang);
                if ($codes[0] == 'i') {
                    // Language not listed in ISO 639 that are not variants
                    // of any listed language, which can be registered with the
                    // i-prefix, such as i-cherokee
                    if (count($codes) > 1) {
                        $lang = $codes[1];
                    }
                } else {
                    for ($i = 0, $max = count($codes); $i < $max; ++$i) {
                        if ($i == 0) {
                            $lang = strtolower($codes[0]);
                        } else {
                            $lang .= '_'.strtoupper($codes[$i]);
                        }
                    }
                }
            }

            $browserLanguages[] = $lang;
        }

        return $browserLanguages;
    }
243217
public function getExtraParams(Request $request)
    {
        $params = array();
        foreach ($this->widgets as $widget) {
            $params = array_merge($params, $widget->getExtraParams($request));
        }

        return $params;
    }
1279943
public function getMessage($messageId, $parameters = [], $locale = "en")
    {
        return $this->translations->getTranslation($messageId, $parameters, $locale);
    }
382269
public function getCredentials(Request $request)
    {
        $tokenExtractor = $this->getTokenExtractor();

        if (!$tokenExtractor instanceof TokenExtractorInterface) {
            throw new \RuntimeException(sprintf('Method "%s::getTokenExtractor()" must return an instance of "%s".', __CLASS__, TokenExtractorInterface::class));
        }

        if (false === ($jsonWebToken = $tokenExtractor->extract($request))) {
            return;
        }

        $preAuthToken = new PreAuthenticationJWTUserToken($jsonWebToken);

        try {
            if (!$payload = $this->jwtManager->decode($preAuthToken)) {
                throw new InvalidTokenException('Invalid JWT Token');
            }

            $preAuthToken->setPayload($payload);
        } catch (JWTDecodeFailureException $e) {
            if (JWTDecodeFailureException::EXPIRED_TOKEN === $e->getReason()) {
                throw new ExpiredTokenException();
            }

            throw new InvalidTokenException('Invalid JWT Token', 0, $e);
        }

        return $preAuthToken;
    }
161334
public function messagesSendAction(Request $request)
    {
        $query = $request->request->all();
        $messages = $this->om->findList('Claroline\PlannedNotificationBundle\Entity\Message', 'uuid', $query['messages']);
        $users = $this->om->findList('Claroline\CoreBundle\Entity\User', 'uuid', $query['users']);
        $this->manager->sendMessages($messages, $users);

        return new JsonResponse('success', 200);
    }
610550
public function saveTemporaryPref(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            $this->app->abort(400);
        }

        $prop = $request->request->get('prop');
        $value = $request->request->get('value');
        $success = false;
        $msg = $this->app->trans('Error while saving preference');

        if (!is_null($prop) && !is_null($value)) {
            $this->getSession()->set('phraseanet.' . $prop, $value);
            $success = true;
            $msg = $this->app->trans('Preference saved !');
        }

        return new JsonResponse(['success' => $success, 'message' => $msg]);
    }
1313139
private function getListRepresentation($request)
    {
        /** @var RestHelperInterface $restHelper */
        $restHelper = $this->get('sulu_core.doctrine_rest_helper');

        /** @var DoctrineListBuilderFactory $factory */
        $factory = $this->get('sulu_core.doctrine_list_builder_factory');

        $listBuilder = $factory->create(self::$entityName);

        $locale = $this->getProductLocaleManager()->retrieveLocale($this->getUser(), $request->get('locale'));

        $restHelper->initializeListBuilder(
            $listBuilder,
            $this->getManager()->getFieldDescriptors($locale)
        );

        $list = new ListRepresentation(
            $listBuilder->execute(),
            self::$entityKey,
            'get_attributes',
            $request->query->all(),
            $listBuilder->getCurrentPage(),
            $listBuilder->getLimit(),
            $listBuilder->count()
        );

        return $list;
    }
159573
public function getExtraParams(Request $request)
    {
        $params = array();
        $editPagePart = $request->get('edit');
        if (isset($editPagePart)) {
            $params['editpagepart'] = $editPagePart;
        }

        return $params;
    }
881870
public function prepareTranslations(&$request)
    {
        $translations = [];

        // Translatable Fields
        $transFields = $this->getTranslatableAttributes();

        foreach ($transFields as $field) {
            $trans = json_decode($request->input($field.'_i18n'), true);

            // Set the default local value
            $request->merge([$field => $trans[config('admin.multilingual.default', 'en')]]);

            $translations[$field] = $this->setAttributeTranslations(
                $field,
                $trans
            );

            // Remove field hidden input
            unset($request[$field.'_i18n']);
        }

        // Remove language selector input
        unset($request['i18n_selector']);

        return $translations;
    }
445558
public function getMangaCharacters(Request\Manga\MangaCharactersRequest $request): array
    {
        $crawler = $this->ghoutte->request('GET', $request->getPath());
        try {
            $parser = new Parser\Manga\CharactersParser($crawler);

            return $parser->getCharacters();
        } catch (\Exception $e) {
            throw ParserException::fromRequest($request, $e);
        }
    }
27201
protected function parseIncomingRequest($request)
    {
        if (! $request) {
            $request = LumenRequest::capture();
        }

        $this->instance(Request::class, $this->prepareRequest($request));

        return [$request->getMethod(), '/'.\trim($request->getPathInfo(), '/')];
    }