Formats the specified response.
@param \yii\web\Response $response the response to be formatted.
778714
public function format($response)
    {
        $response->getHeaders()->set('Content-Type', 'text');
        //$response->setDownloadHeaders('error.pdf', 'application/pdf');
        //$response->setStatusCode(200);
        if ($response->data === null) {
            return;
        }

        echo '<pre>';
        var_export($response->data);

        /*
        $renderer = new \mPDF(
            'pl-x', // mode
            'A4', // format
            0, // font-size
            '', // font
            12, // margin-left
            12, // margin-right
            5, // margin-top
            5, // margin-bottom
            2, // margin-header
            2, // margin-footer
            'P' // orientation
        );
        $renderer->useSubstitutions = true;
        $renderer->simpleTables = false;
        if ($response->data !== null) {
            @$renderer->WriteHTML(\yii\helpers\Html::encode(var_export($response->data, true)));
        }
        $response->content = $renderer->Output('print', 'S');
        */
    }
1333320
private function _buildResponse($response)
    {
        $sections = explode("\r\n\r\n", $response, 2);
        $body = isset($sections[1]) ? $sections[1] : NULL;
        $headers = array();
        $headerlines = explode("\n", $sections[0]);

        // process status
        list($http, $code, $message) = explode(' ', $headerlines[0], 3);

        // process headers
        foreach (array_slice($headerlines, 1) as $headerline) {
            $headers[] = HeaderField::fromString($headerline);
        }

        $response = new Response($code, $headers, $body);

        return $response;
    }
5513
protected function setResponseData(Response $response, array $data)
    {
        if ($response instanceof JsonResponse) {
            /** @var $response JsonResponse */
            return $response->setData($data);
        }

        $content = json_encode($data, JsonResponse::DEFAULT_ENCODING_OPTIONS);

        return $response->setContent($content);
    }
473831
public function format(array $response)
    {
        $this->logger->debug('Category:format');
        $car = '<br />';
        $format = '';
        foreach ($response as $category) {
            $format .= '<div class="category">'
            . '<span class="title">'
            . Tools::safeString(Tools::getFromArray($category, 'title'))
            . '</span>'
            . $car . 'pageid: ' . '<span class="pageid">' . Tools::getFromArray($category, 'pageid') . '</span>'
            . $car . 'files: ' . Tools::getFromArray($category, 'files')
            . $car . 'pages: ' . Tools::getFromArray($category, 'pages')
            . $car . 'subcats: ' . Tools::getFromArray($category, 'subcats')
            . $car . 'size: ' . Tools::getFromArray($category, 'size')
            . $car . 'hidden: ' . (isset($category['hidden']) && $category['hidden'] ? 'true' : 'false')
            .'</div>';
        }
        return $format;
    }
26674
public function ready(Response $response) {
        if ($this->isEmpty()) {
            return $response->html('success');
        }
        $xml = $this->makeXml();
        Factory::log()->info('MESSAGE RESPONSE:'.$xml);
        return $response->xml($xml);
    }
669314
public function processResponse(Response $response) {
		if ($this->logCode) {
			$response->headers->set('C-Code-For-Logger', $this->logCode);
		}
	}
450710
private function transformResponse($response)
    {
        if (is_null($response)) {
            return;
        }

        if ($body = $response->getBody()) {
            $body = new Stream($body->getStream());
        } else {
            $body = null;
        }

        $transformed = new Response(
            $response->getStatusCode(),
            null,
            $response->getHeaders(),
            $body,
            $response->getProtocolVersion()
        );

        return $transformed;
    }
378082
protected function formatPdf($response)
	{
		$mpdf = new \mPDF($this->mode,
			$this->format,
			$this->defaultFontSize,
			$this->defaultFont,
			$this->marginLeft,
			$this->marginRight,
			$this->marginTop,
			$this->marginBottom,
			$this->marginHeader,
			$this->marginFooter,
			$this->orientation
		);

		foreach ($this->options as $key => $option) {
			$mpdf->$key = $option;
		}

		if ($this->beforeRender instanceof \Closure) {
			call_user_func($this->beforeRender, $mpdf, $response->data);
		}

		$mpdf->WriteHTML($response->data);
		return $mpdf->Output('', 'S');
	}
683651
protected function response(Response $response)
    {
        return $this->response->create(
            (string)$response->getContent(),
            $response->getStatusCode(),
            (array)$response->headers->all()
        );
    }
337294
protected function sendResponse($response)
	{
		return $this->responsePreparer->readyForResponses() && ! $this->runningInConsole()
								? $response
								: $response->send();
	}
64974
public function formatActionResponseProperty(ResponseProperty $responseProperty)
    {
        $info = [
            'name' => $responseProperty->getName(),
            'type' => $responseProperty->getType(),
            'description' => $responseProperty->getDescription()
        ];

        if ($responseProperty->isObject() || $responseProperty->isCollection()) {
            foreach ($responseProperty->getChild() as $resProperty) {
                $info['properties'][$resProperty->getName()] = $this->formatActionResponseProperty($resProperty);
            }
        }

        return $info;
    }
1029928
public function format($response)
    {
        //$response->getHeaders()->set('Content-Type', 'application/vnd.ms-excel');
        $response->setDownloadHeaders(basename(\Yii::$app->request->pathInfo) . '.xls', 'application/vnd.ms-excel');
        if ($response->data === null) {
            return;
        }

        \PHPExcel_Settings::setCacheStorageMethod(\PHPExcel_CachedObjectStorageFactory::cache_to_sqlite3);

        $styles = $this->getStyles();

        $objPHPExcel = new \PHPExcel();
        $sheet       = $objPHPExcel->getActiveSheet();

        $offset = 1;

        /*
         * serialize filter
        $sheet->setCellValue('A1', $opcje['nazwaAnaliza']);
        $sheet->duplicateStyle($styles['default'], 'A1:C4');
        $sheet->getRowDimension(1)->setRowHeight(18);
        $sheet->getStyle('A1')->getFont()->setBold(true)->setSize(15);
        $sheet->getStyle('C3:C4')->getFont()->setBold(true);
        $offset = 6;
        */

        $data = $response->data;
        if (!isset($data['items'])) {
            // single model
            $this->addLine($sheet, $offset, array_keys($data));
            $this->addLine($sheet, $offset + 1, array_values($data));
            for ($i = 1, $lastColumn = 'A'; $i < count($data); $i++, $lastColumn++);
            $sheet->duplicateStyle($styles['header'], 'A'.$offset.':'.$lastColumn.$offset);
        } else {
            // a collection of models
            if (($firstRow = reset($data['items'])) !== false) {
                $this->addLine($sheet, $offset, array_keys($firstRow));
            }
            $startOffset = ++$offset;
            $item = [];
            foreach ($data['items'] as $item) {
                $this->addLine($sheet, $offset++, $item);
            }
            $this->addSummaryRow($sheet, $startOffset, $offset, $item);
        }

        $filename = tempnam(\Yii::getAlias('@runtime'), 'xls');
        $objWriter = new \PHPExcel_Writer_Excel5($objPHPExcel);
        $objWriter->save($filename);

        $response->content = file_get_contents($filename);
        unlink($filename);
    }
876827
public function load(Response $response) : void
    {
        $this->response = $response;
        $this->checkModule();
        if ($this->response->getStatusCode() === 200) {
            try {
                $this->loadModule();
            } catch (\Exception $exception) {
                // If an exception is thrown in the code and not caught, switch over to the error handler
                $this->response->setStatusCode(500);
                $this->loadErrorModule();
            }
        } else {
            $this->loadErrorModule();
        }
    }
502320
private function performResponse($response)
    {
        $data = false;
        if ($response instanceof ResponseInterface) {
            $data = json_decode($response->getBody()->getContents());
            $this->getValidationResponse()->validateResponseData($data);
        }

        return $data;
    }
912337
protected function _withCustomHeaders($response)
    {
        foreach ((array)$this->getConfig('headers') as $key => $value) {
            $response = $response->withHeader($key, $value);
        }

        return $response;
    }
439684
public function setResponse($response)
    {
        $xml = simplexml_load_string($response);
        if (!empty($xml->error)) {
            $this->message = (string) $xml->error;
        }
    }
1201520
protected function prepare()
    {
        if ($this->bodyRange !== null) {
            return;
        }

        if (isset($this->formatters[$this->format])) {
            $formatter = $this->formatters[$this->format];
            if (!is_object($formatter)) {
                $this->formatters[$this->format] = $formatter = Yii::createObject($formatter);
            }
            if ($formatter instanceof ResponseFormatterInterface) {
                $formatter->format($this);
                return;
            }
            throw new InvalidConfigException("The '{$this->format}' response formatter is invalid. It must implement the ResponseFormatterInterface.");
        } elseif ($this->format !== self::FORMAT_RAW) {
            throw new InvalidConfigException("Unsupported response format: {$this->format}");
        }

        if ($this->data !== null) {
            if (is_array($this->data)) {
                throw new InvalidArgumentException('Response raw data must not be an array.');
            } elseif (is_object($this->data)) {
                if (method_exists($this->data, '__toString')) {
                    $content = $this->data->__toString();
                } else {
                    throw new InvalidArgumentException('Response raw data must be a string or an object implementing '
                        . ' __toString().');
                }
            } else {
                $content = $this->data;
            }

            $body = new MemoryStream();
            $body->write($content);
            $this->setBody($body);
        }
    }