revert back to more sensible architecture.
This commit is contained in:
@@ -2,30 +2,12 @@
|
||||
|
||||
class Cookie {
|
||||
|
||||
/**
|
||||
* All of the cookies for the current request.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $cookies;
|
||||
|
||||
/**
|
||||
* The cookies that will be sent to the browser at the end of the request.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $queue = array();
|
||||
|
||||
/**
|
||||
* Create a new cookie manager instance.
|
||||
*
|
||||
* @param array $cookies
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(&$cookies)
|
||||
{
|
||||
$this->cookies = &$cookies;
|
||||
}
|
||||
protected static $queue = array();
|
||||
|
||||
/**
|
||||
* Determine if a cookie exists.
|
||||
@@ -33,9 +15,9 @@ class Cookie {
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function has($name)
|
||||
public static function has($name)
|
||||
{
|
||||
return ! is_null($this->get($name));
|
||||
return ! is_null(static::get($name));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,9 +35,9 @@ class Cookie {
|
||||
* @param mixed $default
|
||||
* @return string
|
||||
*/
|
||||
public function get($name, $default = null)
|
||||
public static function get($name, $default = null)
|
||||
{
|
||||
return Arr::get($this->cookies, $name, $default);
|
||||
return Arr::get($_COOKIE, $name, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,9 +51,9 @@ class Cookie {
|
||||
* @param bool $http_only
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($name, $value, $path = '/', $domain = null, $secure = false, $http_only = false)
|
||||
public static function forever($name, $value, $path = '/', $domain = null, $secure = false, $http_only = false)
|
||||
{
|
||||
return $this->put($name, $value, 2628000, $path, $domain, $secure, $http_only);
|
||||
return static::put($name, $value, 2628000, $path, $domain, $secure, $http_only);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,13 +82,13 @@ class Cookie {
|
||||
* @param bool $http_only
|
||||
* @return bool
|
||||
*/
|
||||
public function put($name, $value, $minutes = 0, $path = '/', $domain = null, $secure = false, $http_only = false)
|
||||
public static function put($name, $value, $minutes = 0, $path = '/', $domain = null, $secure = false, $http_only = false)
|
||||
{
|
||||
if ($minutes < 0) unset($this->cookies[$name]);
|
||||
if ($minutes < 0) unset($_COOKIE[$name]);
|
||||
|
||||
$time = ($minutes != 0) ? time() + ($minutes * 60) : 0;
|
||||
|
||||
$this->queue[] = compact('name', 'value', 'time', 'path', 'domain', 'secure', 'http_only');
|
||||
static::$queue[] = compact('name', 'value', 'time', 'path', 'domain', 'secure', 'http_only');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,9 +98,9 @@ class Cookie {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function send()
|
||||
public static function send()
|
||||
{
|
||||
foreach ($this->queue as $cookie)
|
||||
foreach (static::$queue as $cookie)
|
||||
{
|
||||
call_user_func_array('setcookie', $cookie);
|
||||
}
|
||||
@@ -130,9 +112,9 @@ class Cookie {
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function forget($name)
|
||||
public static function forget($name)
|
||||
{
|
||||
return $this->put($name, null, -60);
|
||||
return static::put($name, null, -60);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user