update v 1.0.7.5
This commit is contained in:
@@ -1,36 +1,37 @@
|
||||
<?php namespace Illuminate\Http\Exception;
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Http\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class HttpResponseException extends RuntimeException {
|
||||
class HttpResponseException extends RuntimeException
|
||||
{
|
||||
/**
|
||||
* The underlying response instance.
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* The underlying response instance.
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* Create a new HTTP response exception instance.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Response $response
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Response $response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying response instance.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
/**
|
||||
* Create a new HTTP response exception instance.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Response $response
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Response $response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying response instance.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?php namespace Illuminate\Http\Exception;
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Http\Exception;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PostTooLargeException extends Exception {}
|
||||
class PostTooLargeException extends Exception
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
@@ -1,79 +1,94 @@
|
||||
<?php namespace Illuminate\Http;
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Http;
|
||||
|
||||
use JsonSerializable;
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Contracts\Support\Jsonable;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse as BaseJsonResponse;
|
||||
|
||||
class JsonResponse extends BaseJsonResponse {
|
||||
class JsonResponse extends BaseJsonResponse
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
use ResponseTrait;
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @param int $status
|
||||
* @param array $headers
|
||||
* @param int $options
|
||||
*/
|
||||
public function __construct($data = null, $status = 200, $headers = [], $options = 0)
|
||||
{
|
||||
$this->encodingOptions = $options;
|
||||
|
||||
/**
|
||||
* The json encoding options.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $jsonOptions;
|
||||
parent::__construct($data, $status, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @param int $status
|
||||
* @param array $headers
|
||||
* @param int $options
|
||||
*/
|
||||
public function __construct($data = null, $status = 200, $headers = array(), $options = 0)
|
||||
{
|
||||
$this->jsonOptions = $options;
|
||||
/**
|
||||
* Get the json_decoded data from the response.
|
||||
*
|
||||
* @param bool $assoc
|
||||
* @param int $depth
|
||||
* @return mixed
|
||||
*/
|
||||
public function getData($assoc = false, $depth = 512)
|
||||
{
|
||||
return json_decode($this->data, $assoc, $depth);
|
||||
}
|
||||
|
||||
parent::__construct($data, $status, $headers);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setData($data = [])
|
||||
{
|
||||
if ($data instanceof Arrayable) {
|
||||
$this->data = json_encode($data->toArray(), $this->encodingOptions);
|
||||
} elseif ($data instanceof Jsonable) {
|
||||
$this->data = $data->toJson($this->encodingOptions);
|
||||
} elseif ($data instanceof JsonSerializable) {
|
||||
$this->data = json_encode($data->jsonSerialize(), $this->encodingOptions);
|
||||
} else {
|
||||
$this->data = json_encode($data, $this->encodingOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the json_decoded data from the response.
|
||||
*
|
||||
* @param bool $assoc
|
||||
* @param int $depth
|
||||
* @return mixed
|
||||
*/
|
||||
public function getData($assoc = false, $depth = 512)
|
||||
{
|
||||
return json_decode($this->data, $assoc, $depth);
|
||||
}
|
||||
if (JSON_ERROR_NONE !== json_last_error()) {
|
||||
throw new InvalidArgumentException(json_last_error_msg());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setData($data = array())
|
||||
{
|
||||
$this->data = $data instanceof Jsonable
|
||||
? $data->toJson($this->jsonOptions)
|
||||
: json_encode($data, $this->jsonOptions);
|
||||
return $this->update();
|
||||
}
|
||||
|
||||
return $this->update();
|
||||
}
|
||||
/**
|
||||
* Get the JSON encoding options.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getJsonOptions()
|
||||
{
|
||||
return $this->getEncodingOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the JSON encoding options.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getJsonOptions()
|
||||
{
|
||||
return $this->jsonOptions;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setEncodingOptions($encodingOptions)
|
||||
{
|
||||
return $this->setJsonOptions($encodingOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the JSON encoding options.
|
||||
*
|
||||
* @param int $options
|
||||
* @return mixed
|
||||
*/
|
||||
public function setJsonOptions($options)
|
||||
{
|
||||
$this->jsonOptions = $options;
|
||||
|
||||
return $this->setData($this->getData());
|
||||
}
|
||||
/**
|
||||
* Set the JSON encoding options.
|
||||
*
|
||||
* @param int $options
|
||||
* @return mixed
|
||||
*/
|
||||
public function setJsonOptions($options)
|
||||
{
|
||||
$this->encodingOptions = (int) $options;
|
||||
|
||||
return $this->setData($this->getData());
|
||||
}
|
||||
}
|
||||
|
||||
27
vendor/laravel/framework/src/Illuminate/Http/Middleware/CheckResponseForModifications.php
vendored
Normal file
27
vendor/laravel/framework/src/Illuminate/Http/Middleware/CheckResponseForModifications.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CheckResponseForModifications
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
|
||||
if ($response instanceof Response) {
|
||||
$response->isNotModified($request);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
<?php namespace Illuminate\Http\Middleware;
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Routing\Middleware;
|
||||
|
||||
class FrameGuard implements Middleware {
|
||||
class FrameGuard
|
||||
{
|
||||
/**
|
||||
* Handle the given request and get the response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
|
||||
/**
|
||||
* Handle the given request and get the response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
|
||||
$response->headers->set('X-Frame-Options', 'SAMEORIGIN', false);
|
||||
|
||||
return $response;
|
||||
}
|
||||
$response->headers->set('X-Frame-Options', 'SAMEORIGIN', false);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,204 +1,200 @@
|
||||
<?php namespace Illuminate\Http;
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Http;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Illuminate\Support\ViewErrorBag;
|
||||
use Illuminate\Session\Store as SessionStore;
|
||||
use Illuminate\Contracts\Support\MessageProvider;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse as BaseRedirectResponse;
|
||||
|
||||
class RedirectResponse extends BaseRedirectResponse {
|
||||
class RedirectResponse extends BaseRedirectResponse
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
use ResponseTrait;
|
||||
/**
|
||||
* The request instance.
|
||||
*
|
||||
* @var \Illuminate\Http\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* The request instance.
|
||||
*
|
||||
* @var \Illuminate\Http\Request
|
||||
*/
|
||||
protected $request;
|
||||
/**
|
||||
* The session store implementation.
|
||||
*
|
||||
* @var \Illuminate\Session\Store
|
||||
*/
|
||||
protected $session;
|
||||
|
||||
/**
|
||||
* The session store implementation.
|
||||
*
|
||||
* @var \Illuminate\Session\Store
|
||||
*/
|
||||
protected $session;
|
||||
/**
|
||||
* Flash a piece of data to the session.
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param mixed $value
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function with($key, $value = null)
|
||||
{
|
||||
$key = is_array($key) ? $key : [$key => $value];
|
||||
|
||||
/**
|
||||
* Flash a piece of data to the session.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function with($key, $value = null)
|
||||
{
|
||||
$key = is_array($key) ? $key : [$key => $value];
|
||||
foreach ($key as $k => $v) {
|
||||
$this->session->flash($k, $v);
|
||||
}
|
||||
|
||||
foreach ($key as $k => $v)
|
||||
{
|
||||
$this->session->flash($k, $v);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Add multiple cookies to the response.
|
||||
*
|
||||
* @param array $cookies
|
||||
* @return $this
|
||||
*/
|
||||
public function withCookies(array $cookies)
|
||||
{
|
||||
foreach ($cookies as $cookie) {
|
||||
$this->headers->setCookie($cookie);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add multiple cookies to the response.
|
||||
*
|
||||
* @param array $cookies
|
||||
* @return $this
|
||||
*/
|
||||
public function withCookies(array $cookies)
|
||||
{
|
||||
foreach ($cookies as $cookie)
|
||||
{
|
||||
$this->headers->setCookie($cookie);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Flash an array of input to the session.
|
||||
*
|
||||
* @param array $input
|
||||
* @return $this
|
||||
*/
|
||||
public function withInput(array $input = null)
|
||||
{
|
||||
$input = $input ?: $this->request->input();
|
||||
|
||||
/**
|
||||
* Flash an array of input to the session.
|
||||
*
|
||||
* @param array $input
|
||||
* @return $this
|
||||
*/
|
||||
public function withInput(array $input = null)
|
||||
{
|
||||
$input = $input ?: $this->request->input();
|
||||
$this->session->flashInput($data = array_filter($input, $callback = function (&$value) use (&$callback) {
|
||||
if (is_array($value)) {
|
||||
$value = array_filter($value, $callback);
|
||||
}
|
||||
|
||||
$this->session->flashInput($data = array_filter($input, $callback = function (&$value) use (&$callback)
|
||||
{
|
||||
if (is_array($value))
|
||||
{
|
||||
$value = array_filter($value, $callback);
|
||||
}
|
||||
return ! $value instanceof SymfonyUploadedFile;
|
||||
}));
|
||||
|
||||
return ! $value instanceof UploadedFile;
|
||||
}));
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Flash an array of input to the session.
|
||||
*
|
||||
* @param mixed string
|
||||
* @return $this
|
||||
*/
|
||||
public function onlyInput()
|
||||
{
|
||||
return $this->withInput($this->request->only(func_get_args()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Flash an array of input to the session.
|
||||
*
|
||||
* @param mixed string
|
||||
* @return $this
|
||||
*/
|
||||
public function onlyInput()
|
||||
{
|
||||
return $this->withInput($this->request->only(func_get_args()));
|
||||
}
|
||||
/**
|
||||
* Flash an array of input to the session.
|
||||
*
|
||||
* @param mixed string
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function exceptInput()
|
||||
{
|
||||
return $this->withInput($this->request->except(func_get_args()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Flash an array of input to the session.
|
||||
*
|
||||
* @param mixed string
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function exceptInput()
|
||||
{
|
||||
return $this->withInput($this->request->except(func_get_args()));
|
||||
}
|
||||
/**
|
||||
* Flash a container of errors to the session.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Support\MessageProvider|array|string $provider
|
||||
* @param string $key
|
||||
* @return $this
|
||||
*/
|
||||
public function withErrors($provider, $key = 'default')
|
||||
{
|
||||
$value = $this->parseErrors($provider);
|
||||
|
||||
/**
|
||||
* Flash a container of errors to the session.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Support\MessageProvider|array|string $provider
|
||||
* @param string $key
|
||||
* @return $this
|
||||
*/
|
||||
public function withErrors($provider, $key = 'default')
|
||||
{
|
||||
$value = $this->parseErrors($provider);
|
||||
$this->session->flash(
|
||||
'errors', $this->session->get('errors', new ViewErrorBag)->put($key, $value)
|
||||
);
|
||||
|
||||
$this->session->flash(
|
||||
'errors', $this->session->get('errors', new ViewErrorBag)->put($key, $value)
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Parse the given errors into an appropriate value.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Support\MessageProvider|array|string $provider
|
||||
* @return \Illuminate\Support\MessageBag
|
||||
*/
|
||||
protected function parseErrors($provider)
|
||||
{
|
||||
if ($provider instanceof MessageProvider) {
|
||||
return $provider->getMessageBag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given errors into an appropriate value.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Support\MessageProvider|array|string $provider
|
||||
* @return \Illuminate\Support\MessageBag
|
||||
*/
|
||||
protected function parseErrors($provider)
|
||||
{
|
||||
if ($provider instanceof MessageProvider)
|
||||
{
|
||||
return $provider->getMessageBag();
|
||||
}
|
||||
return new MessageBag((array) $provider);
|
||||
}
|
||||
|
||||
return new MessageBag((array) $provider);
|
||||
}
|
||||
/**
|
||||
* Get the request instance.
|
||||
*
|
||||
* @return \Illuminate\Http\Request|null
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request instance.
|
||||
*
|
||||
* @return \Illuminate\Http\Request
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
/**
|
||||
* Set the request instance.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*/
|
||||
public function setRequest(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the request instance.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*/
|
||||
public function setRequest(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
/**
|
||||
* Get the session store implementation.
|
||||
*
|
||||
* @return \Illuminate\Session\Store|null
|
||||
*/
|
||||
public function getSession()
|
||||
{
|
||||
return $this->session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the session store implementation.
|
||||
*
|
||||
* @return \Illuminate\Session\Store
|
||||
*/
|
||||
public function getSession()
|
||||
{
|
||||
return $this->session;
|
||||
}
|
||||
/**
|
||||
* Set the session store implementation.
|
||||
*
|
||||
* @param \Illuminate\Session\Store $session
|
||||
* @return void
|
||||
*/
|
||||
public function setSession(SessionStore $session)
|
||||
{
|
||||
$this->session = $session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the session store implementation.
|
||||
*
|
||||
* @param \Illuminate\Session\Store $session
|
||||
* @return void
|
||||
*/
|
||||
public function setSession(SessionStore $session)
|
||||
{
|
||||
$this->session = $session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically bind flash data in the session.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return void
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
if (starts_with($method, 'with'))
|
||||
{
|
||||
return $this->with(snake_case(substr($method, 4)), $parameters[0]);
|
||||
}
|
||||
|
||||
throw new BadMethodCallException("Method [$method] does not exist on Redirect.");
|
||||
}
|
||||
/**
|
||||
* Dynamically bind flash data in the session.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return $this
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
if (Str::startsWith($method, 'with')) {
|
||||
return $this->with(Str::snake(substr($method, 4)), $parameters[0]);
|
||||
}
|
||||
|
||||
throw new BadMethodCallException("Method [$method] does not exist on Redirect.");
|
||||
}
|
||||
}
|
||||
|
||||
1833
vendor/laravel/framework/src/Illuminate/Http/Request.php
vendored
1833
vendor/laravel/framework/src/Illuminate/Http/Request.php
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,86 +1,110 @@
|
||||
<?php namespace Illuminate\Http;
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Http;
|
||||
|
||||
use Exception;
|
||||
use ArrayObject;
|
||||
use JsonSerializable;
|
||||
use Illuminate\Contracts\Support\Jsonable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Symfony\Component\HttpFoundation\Response as BaseResponse;
|
||||
|
||||
class Response extends BaseResponse {
|
||||
class Response extends BaseResponse
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
use ResponseTrait;
|
||||
/**
|
||||
* The original content of the response.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $original;
|
||||
|
||||
/**
|
||||
* The original content of the response.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $original;
|
||||
/**
|
||||
* The exception that triggered the error response (if applicable).
|
||||
*
|
||||
* @var \Exception
|
||||
*/
|
||||
public $exception;
|
||||
|
||||
/**
|
||||
* Set the content on the response.
|
||||
*
|
||||
* @param mixed $content
|
||||
* @return $this
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->original = $content;
|
||||
/**
|
||||
* Set the content on the response.
|
||||
*
|
||||
* @param mixed $content
|
||||
* @return $this
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->original = $content;
|
||||
|
||||
// If the content is "JSONable" we will set the appropriate header and convert
|
||||
// the content to JSON. This is useful when returning something like models
|
||||
// from routes that will be automatically transformed to their JSON form.
|
||||
if ($this->shouldBeJson($content))
|
||||
{
|
||||
$this->header('Content-Type', 'application/json');
|
||||
// If the content is "JSONable" we will set the appropriate header and convert
|
||||
// the content to JSON. This is useful when returning something like models
|
||||
// from routes that will be automatically transformed to their JSON form.
|
||||
if ($this->shouldBeJson($content)) {
|
||||
$this->header('Content-Type', 'application/json');
|
||||
|
||||
$content = $this->morphToJson($content);
|
||||
}
|
||||
$content = $this->morphToJson($content);
|
||||
}
|
||||
|
||||
// If this content implements the "Renderable" interface then we will call the
|
||||
// render method on the object so we will avoid any "__toString" exceptions
|
||||
// that might be thrown and have their errors obscured by PHP's handling.
|
||||
elseif ($content instanceof Renderable)
|
||||
{
|
||||
$content = $content->render();
|
||||
}
|
||||
// If this content implements the "Renderable" interface then we will call the
|
||||
// render method on the object so we will avoid any "__toString" exceptions
|
||||
// that might be thrown and have their errors obscured by PHP's handling.
|
||||
elseif ($content instanceof Renderable) {
|
||||
$content = $content->render();
|
||||
}
|
||||
|
||||
return parent::setContent($content);
|
||||
}
|
||||
return parent::setContent($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Morph the given content into JSON.
|
||||
*
|
||||
* @param mixed $content
|
||||
* @return string
|
||||
*/
|
||||
protected function morphToJson($content)
|
||||
{
|
||||
if ($content instanceof Jsonable) return $content->toJson();
|
||||
/**
|
||||
* Morph the given content into JSON.
|
||||
*
|
||||
* @param mixed $content
|
||||
* @return string
|
||||
*/
|
||||
protected function morphToJson($content)
|
||||
{
|
||||
if ($content instanceof Jsonable) {
|
||||
return $content->toJson();
|
||||
}
|
||||
|
||||
return json_encode($content);
|
||||
}
|
||||
return json_encode($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given content should be turned into JSON.
|
||||
*
|
||||
* @param mixed $content
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldBeJson($content)
|
||||
{
|
||||
return $content instanceof Jsonable ||
|
||||
$content instanceof ArrayObject ||
|
||||
is_array($content);
|
||||
}
|
||||
/**
|
||||
* Determine if the given content should be turned into JSON.
|
||||
*
|
||||
* @param mixed $content
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldBeJson($content)
|
||||
{
|
||||
return $content instanceof Jsonable ||
|
||||
$content instanceof ArrayObject ||
|
||||
$content instanceof JsonSerializable ||
|
||||
is_array($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the original response content.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOriginalContent()
|
||||
{
|
||||
return $this->original;
|
||||
}
|
||||
/**
|
||||
* Get the original response content.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOriginalContent()
|
||||
{
|
||||
return $this->original;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the exception to attach to the response.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @return $this
|
||||
*/
|
||||
public function withException(Exception $e)
|
||||
{
|
||||
$this->exception = $e;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,96 @@
|
||||
<?php namespace Illuminate\Http;
|
||||
<?php
|
||||
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
namespace Illuminate\Http;
|
||||
|
||||
trait ResponseTrait {
|
||||
use Illuminate\Http\Exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
* Set a header on the Response.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @param bool $replace
|
||||
* @return $this
|
||||
*/
|
||||
public function header($key, $value, $replace = true)
|
||||
{
|
||||
$this->headers->set($key, $value, $replace);
|
||||
trait ResponseTrait
|
||||
{
|
||||
/**
|
||||
* Get the status code for the response.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
return $this->getStatusCode();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Get the content of the response.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function content()
|
||||
{
|
||||
return $this->getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a cookie to the response.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Cookie $cookie
|
||||
* @return $this
|
||||
*/
|
||||
public function withCookie(Cookie $cookie)
|
||||
{
|
||||
$this->headers->setCookie($cookie);
|
||||
/**
|
||||
* Set a header on the Response.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @param bool $replace
|
||||
* @return $this
|
||||
*/
|
||||
public function header($key, $value, $replace = true)
|
||||
{
|
||||
$this->headers->set($key, $value, $replace);
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an array of headers to the response.
|
||||
*
|
||||
* @param array $headers
|
||||
* @return $this
|
||||
*/
|
||||
public function withHeaders(array $headers)
|
||||
{
|
||||
foreach ($headers as $key => $value) {
|
||||
$this->headers->set($key, $value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a cookie to the response.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Cookie|mixed $cookie
|
||||
* @return $this
|
||||
*/
|
||||
public function cookie($cookie)
|
||||
{
|
||||
return call_user_func_array([$this, 'withCookie'], func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a cookie to the response.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Cookie|mixed $cookie
|
||||
* @return $this
|
||||
*/
|
||||
public function withCookie($cookie)
|
||||
{
|
||||
if (is_string($cookie) && function_exists('cookie')) {
|
||||
$cookie = call_user_func_array('cookie', func_get_args());
|
||||
}
|
||||
|
||||
$this->headers->setCookie($cookie);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws the response in a HttpResponseException instance.
|
||||
*
|
||||
* @throws Illuminate\Http\Exception\HttpResponseException;
|
||||
*/
|
||||
public function throwResponse()
|
||||
{
|
||||
throw new HttpResponseException($this);
|
||||
}
|
||||
}
|
||||
|
||||
75
vendor/laravel/framework/src/Illuminate/Http/UploadedFile.php
vendored
Normal file
75
vendor/laravel/framework/src/Illuminate/Http/UploadedFile.php
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Http;
|
||||
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;
|
||||
|
||||
class UploadedFile extends SymfonyUploadedFile
|
||||
{
|
||||
use Macroable;
|
||||
|
||||
/**
|
||||
* Get the fully qualified path to the file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function path()
|
||||
{
|
||||
return $this->getRealPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file's extension.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function extension()
|
||||
{
|
||||
return $this->guessExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file's extension supplied by the client.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function clientExtension()
|
||||
{
|
||||
return $this->guessClientExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a filename for the file that is the MD5 hash of the contents.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function hashName($path = null)
|
||||
{
|
||||
if ($path) {
|
||||
$path = rtrim($path, '/').'/';
|
||||
}
|
||||
|
||||
return $path.md5_file($this->path()).'.'.$this->extension();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new file instance from a base instance.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
|
||||
* @param bool $test
|
||||
* @return static
|
||||
*/
|
||||
public static function createFromBase(SymfonyUploadedFile $file, $test = false)
|
||||
{
|
||||
return $file instanceof static ? $file : new static(
|
||||
$file->getPathname(),
|
||||
$file->getClientOriginalName(),
|
||||
$file->getClientMimeType(),
|
||||
$file->getClientSize(),
|
||||
$file->getError(),
|
||||
$test
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,11 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"illuminate/session": "5.0.*",
|
||||
"illuminate/support": "5.0.*",
|
||||
"symfony/http-foundation": "2.6.*",
|
||||
"symfony/http-kernel": "2.6.*"
|
||||
"php": ">=5.5.9",
|
||||
"illuminate/session": "5.2.*",
|
||||
"illuminate/support": "5.2.*",
|
||||
"symfony/http-foundation": "2.8.*|3.0.*",
|
||||
"symfony/http-kernel": "2.8.*|3.0.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -27,7 +27,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
"dev-master": "5.2-dev"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
|
||||
Reference in New Issue
Block a user