Organizes works.

@param bool $mDataSupport
@return \Illuminate\Http\JsonResponse
@throws \Exception
554207
public function make($mDataSupport = true)
    {
        try {
            $this->prepareQuery();

            $results   = $this->results();
            $processed = $this->processResults($results, $mDataSupport);
            $data      = $this->transform($results, $processed);

            return $this->render($data);
        } catch (\Exception $exception) {
            return $this->errorResponse($exception);
        }
    }
802814
public static function responseJsonError($mdata = array(), $status = null, $msg = '', array $headers = array(), $options = 0)
    {
        $response = self::responseError($mdata, $status, $msg);

        return Response::json($response, $response['status'], $headers, $options);
    }
361243
public function menuAction()
    {
        $loader = $this->get('phlexible_gui.menu.loader');
        $items = $loader->load();
        $data = $items->toArray();

        return new JsonResponse($data);
    }
795594
public function listJsonAction()
    {
        $em = $this->getDoctrine()->getManager();

        /** @var \Kitchenit\AdminBundle\Services\DataTables\JsonList $jsonList */
        $jsonList = $this->get('json_list');
        $jsonList->setRepository($em->getRepository('EcommerceBundle:Invoice'));

        $response = $jsonList->get();

        return new JsonResponse($response);
    }
1344071
public function multipart()
    {

        if (empty($this->_multiparts)) {

            $this->_multiparts = array();

            if (!$this->isContentType('multipart/mixed')) {
                throw new Exception('Response is not multipart');
            }

            // Step 1. Get boundary

            preg_match('/boundary=([^";]+)/i', $this->getContentType(), $matches);

            if (empty($matches[1])) {
                throw new Exception('Boundary not found');
            }

            $boundary = $matches[1];

            // Step 2. Split by boundary and remove first and last parts if needed

            $parts = explode('--' . $boundary . '', $this->text()); //TODO Handle as stream

            if (empty(trim($parts[0]))) {
                array_shift($parts);
            }

            if (trim($parts[count($parts) - 1]) == '--') {
                array_pop($parts);
            }

            if (count($parts) == 0) {
                throw new Exception('No parts found');
            }

            // Step 3. Create status info object

            $statusInfoPart = array_shift($parts);
            $statusInfoObj = new self(null,
                self::createResponse(trim($statusInfoPart), $this->response()->getStatusCode())
            );
            $statusInfo = $statusInfoObj->json()->response;

            // Step 4. Parse all parts into Response objects

            foreach ($parts as $i => $part) {

                $partInfo = $statusInfo[$i];

                $this->_multiparts[] = new self(null, self::createResponse(trim($part), $partInfo->status));

            }

        }

        return $this->_multiparts;

    }
979472
public function composeJson(array $data = [], int $status = 200, array $config = []): SymfonyResponse
    {
        return Response::make($this->createJsonResponse($data, $config)(), $status, [
            'Content-Type' => 'application/json',
        ]);
    }
809949
public function handle(array $handlingSubject, array $response) {
        
        /** @var $payment Payment */
        $paymentDO  = SubjectReader::readPayment($handlingSubject);
        $payment    = $paymentDO->getPayment();

        if ( ! $payment instanceof Payment) {
            return;
        }

        // Debug info
        $this->watchdog->bark($response);

        /** 
         * Set transaction info only for non 3DS flow
         * For 3DS flow, this is handled in the webhook callback
         * in order to avoid having a payment token as a transaction id
         */
        if (!isset($response['redirectUrl'])) {
            $this->setTransactionId($payment, $response['id']);
            $payment->setIsTransactionClosed($this->shouldCloseTransaction());
            $payment->setShouldCloseParentTransaction($this->shouldCloseParentTransaction($payment));
        }

        if (array_key_exists('originalId', $response)) {
            $payment->setParentTransactionId($response['originalId']);
        }

        foreach (self::$additionalInformationMapping as $item) {
            if (array_key_exists($item, $response)) {
                $payment->setAdditionalInformation($item, $response[$item]);
            }
        }

        $responseCode = isset($response['responseCode']) ? (int) $response['responseCode'] : null;

        // Process failure response codes
        if ( $responseCode && $responseCode != 10000 && $responseCode != 10100 ) {
            throw new LocalizedException(
                __('The transaction was declined. Please check you card details or contact your card provider.')
            );
        }

        // Process success response codes
        if ($responseCode === 10100) {
            $payment->setIsFraudDetected(true);
        }

        // Prepare 3D Secure redirection with session variable for post auth order
        if (array_key_exists(self::REDIRECT_URL, $response)) {
            
            // Get the 3DS redirection URL
            $redirectUrl = $response[self::REDIRECT_URL];
            
            // Set 3DS redirection in session for the PlaceOrder controller
            $this->session->set3DSRedirect($redirectUrl);

            // Put the response in session for the PlaceOrder controller
            $this->session->setGatewayResponseId($response['id']);
        }

        // Set a flag for card id charge
        if (isset($response['udf2']) && $response['udf2'] == 'cardIdCharge') {
            $this->session->setCardIdChargeFlag('cardIdCharge');
        }

        // Save card if needed
        if (isset($response['udf3']) && $response['udf3'] == 'storeInVaultOnSuccess' && $response['status'] == 'Authorised') {
            $this->vaultCard( $response );
        }
    }
207301
public function getPackageAssetsDirs($jsonData)
    {
        $packagesAssetsDir = null;
        // If some assets were set on the package
        if (isset($jsonData["extra"][self::LABEL_ASSETS_DIR])) {
            // We get the assets-dir of this package
            $packagesAssetsDir = $jsonData["extra"][self::LABEL_ASSETS_DIR];
            if (is_string($packagesAssetsDir)) {
                // If we get a string, it's the public shortcut so we uniform the return
                $packagesAssetsDir = array(self::LABEL_PUBLIC_DIR => $packagesAssetsDir);
            }
        }
        return $packagesAssetsDir;
    }
1165605
public function createSubscription(Create\RequestData $requestData)
    {
        $request = new Create\Request($requestData);

        return $this->sendRequest($request, Create\ApiResponse::class);
    }
299629
public function execute($operationConfig, $operationMetadata, $inputMap) {
        $request = $this->getRequest($operationConfig, $operationMetadata, $inputMap);

        try {
            $response = $this->client->send($request, array_merge(ApiConfig::getProxy(), ApiConfig::getTimeout()));
            $statusCode = $response->getStatusCode();
            $responseContent = $response->getBody()->getContents();
            
            if ($statusCode < self::HTTP_AMBIGUOUS) {
                
                if (ApiConfig::isDebug()) {
                    $this->logger->debug("---------------------");
                    $this->logger->debug(">>request(".$request->getMethod().") ". $request->getUri()->__toString() );    
                    $this->logger->debug(">>headers: ", $request->getHeaders());
                    $this->logger->debug(">>body: ". $request->getBody());
                    
                    $this->logger->debug("<<statusCode: ". $statusCode);
                    $this->logger->debug("<<headers: ", $response->getHeaders());
                    $this->logger->debug("<<body: ". $responseContent);
                    $this->logger->debug("---------------------");
                }
                
                if (strlen($responseContent) > 0) {
                    return json_decode($responseContent, true);
                } else {
                    return array();
                }
            } else {
                $this->handleException($response, $request);
            }
        } catch (RequestException $ex) {
            if ($ex->hasResponse()) {
                $this->handleException($ex->getResponse(), $request);
            } else {
                throw new ApiException($ex->getMessage());
            }
        }
    }
1223414
public function createResponse(Exception $exception)
    {
        $data   = $this->createResponseData($exception);
        $status = $this->resolveResponseStatusCode($exception);

        return new JsonResponse($data, $status, [], JSON_PARTIAL_OUTPUT_ON_ERROR);
    }
751604
public function fillRawData(string $rawData): TelegramResponse
    {
        $this->rawData = $rawData;
        $this->decodedData = json_decode($this->rawData, true);

        if ($this->decodedData['ok'] === false) {
            $exception = new ClientException();
            $exception->setError(new UnsuccessfulRequest($this->decodedData));
            throw $exception;
        }

        return $this;
    }
210083
public function afterActionDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, MbAction $acaombAction)
    {
        $className = static::class;
        $methodName = __METHOD__;
        throw new MbException("{$methodName} not allowed in! {$className}.");
    }
78998
public function onResponseCreation(OnAssembleResponseEvent $event)
    {
        if ($event->isSuccess()) {
            $event->setResponse(new JsonResponse(array(
                $this->apiKeyValue => $this->metadata->getPropertyValue($event->getUser(), ClassMetadata::API_KEY_PROPERTY),
            )));

            return;
        }

        $event->setResponse(new JsonResponse(
            array($this->messageValue => $this->translator->trans($event->getException()->getMessage() ?: 'Credentials refused!')),
            JsonResponse::HTTP_UNAUTHORIZED
        ));
    }
753855
public function setPayload($responseData) {

		try {
			$this->data = json_encode($responseData, $this->encodingOptions);
		}

		catch (\Exception $e) {

			// PHP 5.4 wrap exceptions thrown by JsonSerializable in a new exception that needs to be removed

			if ('Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
				throw $e->getPrevious() ?: $e;
			}
			throw $e;
		}

		if (JSON_ERROR_NONE !== json_last_error()) {
			throw new \InvalidArgumentException(json_last_error_msg());
		}

		return $this->update();

	}
230266
public function executeAjaxActions($arrData)
    {
        \Input::setGet('no_ajax', 1); // Avoid circular reference

        switch (\Input::post('action')) {
            // Upload the file
            case 'fineuploader_upload':
                $arrData['name'] = \Input::post('name');

                /** @var FormFineUploader $objWidget */
                $objWidget = new $GLOBALS['TL_FFL']['fineUploader']($arrData);
                $strFile = $objWidget->validateUpload();

                if ($objWidget->hasErrors()) {
                    $arrResponse = array('success' => false, 'error' => $objWidget->getErrorAsString(), 'preventRetry' => true);
                } else {
                    $arrResponse = array('success' => true, 'file' => $strFile);
                }

                $response = new \Haste\Http\Response\JsonResponse($arrResponse);
                $response->send(false);
                exit;
                break;
        }
    }
495669
public function loadJSONObject($jsonObject)
    {
        if (isset($jsonObject->type)) {
            $this->setType($jsonObject->type);
        }
        if (isset($jsonObject->url)) {
            $this->setUrl($jsonObject->url);
        }
        if (isset($jsonObject->options)) {
            $this->setOptions($jsonObject->options);
        }
        if (isset($jsonObject->package)) {
            $package = new Package();
            $package->setName($jsonObject->package->name)
                ->setVersion($jsonObject->package->version)
                ->setDist($jsonObject->package->dist)
                ->setSource($jsonObject->package->source);

            $this->setPackage($package);
        }

        return $this;
    }