first commit
This commit is contained in:
78
vendor/php-flasher/flasher-laravel/Http/Request.php
vendored
Normal file
78
vendor/php-flasher/flasher-laravel/Http/Request.php
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Laravel\Http;
|
||||
|
||||
use Flasher\Prime\Http\RequestInterface;
|
||||
use Illuminate\Http\Request as LaravelRequest;
|
||||
|
||||
final class Request implements RequestInterface
|
||||
{
|
||||
/**
|
||||
* @var LaravelRequest
|
||||
*/
|
||||
private $request;
|
||||
|
||||
public function __construct(LaravelRequest $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isXmlHttpRequest()
|
||||
{
|
||||
return $this->request->ajax();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isHtmlRequestFormat()
|
||||
{
|
||||
return 'html' === $this->request->getRequestFormat();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hasSession()
|
||||
{
|
||||
return $this->request->hasSession();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hasType($type)
|
||||
{
|
||||
$session = $this->request->session();
|
||||
|
||||
return $session->has($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getType($type)
|
||||
{
|
||||
$session = $this->request->session();
|
||||
|
||||
return $session->get($type); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function forgetType($type)
|
||||
{
|
||||
$session = $this->request->session();
|
||||
|
||||
$session->forget($type);
|
||||
}
|
||||
}
|
90
vendor/php-flasher/flasher-laravel/Http/Response.php
vendored
Normal file
90
vendor/php-flasher/flasher-laravel/Http/Response.php
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Laravel\Http;
|
||||
|
||||
use Flasher\Prime\Http\ResponseInterface;
|
||||
use Illuminate\Http\JsonResponse as LaravelJsonResponse;
|
||||
use Illuminate\Http\Response as LaravelResponse;
|
||||
|
||||
final class Response implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* @var LaravelJsonResponse|LaravelResponse
|
||||
*/
|
||||
private $response;
|
||||
|
||||
/**
|
||||
* @param LaravelJsonResponse|LaravelResponse $response
|
||||
*/
|
||||
public function __construct($response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isRedirection()
|
||||
{
|
||||
return $this->response->isRedirection();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isJson()
|
||||
{
|
||||
return $this->response instanceof LaravelJsonResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isHtml()
|
||||
{
|
||||
$contentType = $this->response->headers->get('Content-Type');
|
||||
|
||||
return false !== stripos($contentType, 'html'); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isAttachment()
|
||||
{
|
||||
$contentDisposition = $this->response->headers->get('Content-Disposition', '');
|
||||
|
||||
return false !== stripos($contentDisposition, 'attachment;'); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->response->getContent(); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
$original = null;
|
||||
if ($this->response instanceof \Illuminate\Http\Response && $this->response->getOriginalContent()) {
|
||||
$original = $this->response->getOriginalContent();
|
||||
}
|
||||
|
||||
$this->response->setContent($content);
|
||||
|
||||
// Restore original response (eg. the View or Ajax data)
|
||||
if ($original) {
|
||||
$this->response->original = $original;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user