# wpide/3.4.2/App/Kernel/Response.php

WPIDE – File Manager &amp; Code Editor, version 3.4.2. 48 lines.

- Page: https://pluginprobe.com/plugins/wpide/3.4.2/code/App/Kernel/Response.php
- Raw: https://pluginprobe.com/plugins/wpide/3.4.2/raw/App/Kernel/Response.php
- Modified: 2022-07-30T20:33:10+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wpide/3.4.2/code/App/Kernel/Response.php#L10-L20`.

```php
<?php

namespace WPIDE\App\Kernel;

use Symfony\Component\HttpFoundation\Response as SymfonyResponse;

class Response extends SymfonyResponse
{
    public function json($content, $status_code = 200, $asIs = false)
    {
        $this->headers->set('Content-Type', 'application/json');
        $this->setStatusCode($status_code);

        if($asIs) {
            $this->setContent($content);
        }else {
            $this->setContent(json_encode([
                'data' => $content,
            ]));
        }
    }

    public function html($content, $status_code = 200)
    {
        $this->setStatusCode($status_code);
        $this->setContent($content);
    }

    public function redirect($url, $status_code = 302)
    {
        $this->setStatusCode($status_code);
        $this->setContent(
            sprintf('<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="refresh" content="0;url=%1$s" />
        <title>Redirecting to %1$s</title>
    </head>
    <body>
        Redirecting to <a href="%1$s">%1$s</a>.
    </body>
</html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8'))
        );
        $this->headers->set('Location', $url);
    }
}

```
