Refactored structure
This commit is contained in:
parent
963225382c
commit
e5164ae1dd
329 changed files with 277 additions and 457 deletions
30
src/B8Framework/Http/Response/JsonResponse.php
Executable file
30
src/B8Framework/Http/Response/JsonResponse.php
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace b8\Http\Response;
|
||||
|
||||
use b8\Http\Response;
|
||||
|
||||
class JsonResponse extends Response
|
||||
{
|
||||
public function __construct(Response $createFrom = null)
|
||||
{
|
||||
parent::__construct($createFrom);
|
||||
|
||||
$this->setContent(array());
|
||||
$this->setHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
public function hasLayout()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function flushBody()
|
||||
{
|
||||
if (isset($this->data['body'])) {
|
||||
return json_encode($this->data['body']);
|
||||
}
|
||||
|
||||
return json_encode(null);
|
||||
}
|
||||
}
|
||||
27
src/B8Framework/Http/Response/RedirectResponse.php
Executable file
27
src/B8Framework/Http/Response/RedirectResponse.php
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace b8\Http\Response;
|
||||
|
||||
use b8\Http\Response;
|
||||
|
||||
class RedirectResponse extends Response
|
||||
{
|
||||
public function __construct(Response $createFrom = null)
|
||||
{
|
||||
parent::__construct($createFrom);
|
||||
|
||||
$this->setContent(null);
|
||||
$this->setResponseCode(302);
|
||||
}
|
||||
|
||||
public function hasLayout()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function flush()
|
||||
{
|
||||
parent::flush();
|
||||
die;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue