Skip to content

Commit

Permalink
mod Response
Browse files Browse the repository at this point in the history
  • Loading branch information
shayanderson committed Jun 22, 2019
1 parent c224c09 commit 400e9de
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Eco Framework
Eco is a PHP Framework for PHP 5.5+

Latest release [v1.7.0](https://github.com/shayanderson/eco/releases/latest)
Latest release [v1.7.1](https://github.com/shayanderson/eco/releases/latest)

Install example:
```
Expand Down
18 changes: 15 additions & 3 deletions app/vendor/Eco/System/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function cookieRemove($key, $path = '/')
/**
* Cookie sender (see more docs at <http://www.php.net/manual/en/function.setcookie.php>)
*
* @param string $name (ex: 'my_id')
* @param string $key (ex: 'my_id')
* @param mixed $value (cookie value)
* @param mixed $expire (string ex: '+30 days', int ex: time() + 3600 (expire in 1 hour))
* @param string $path (optional, ex: '/account' (only accessible in /account directory
Expand All @@ -90,15 +90,15 @@ public function cookieRemove($key, $path = '/')
* @param boolean $http_only (accessible only in HTTP protocol)
* @return boolean (false on fail, true on send to client - unknown if client accepts cookie)
*/
public function cookieSet($name, $value, $expire = '+1 day', $path = '/', $domain = null,
public function cookieSet($key, $value, $expire = '+1 day', $path = '/', $domain = null,
$only_secure = false, $http_only = false)
{
if(headers_sent())
{
return false;
}

return setcookie($name, $value, is_string($expire) ? strtotime($expire) : $expire, $path,
return setcookie($key, $value, is_string($expire) ? strtotime($expire) : $expire, $path,
$domain, $only_secure, $http_only);
}

Expand All @@ -107,6 +107,7 @@ public function cookieSet($name, $value, $expire = '+1 day', $path = '/', $domai
*
* @param string $key (ex: "Content-Language")
* @param string $value (ex: "en-US")
* @return void
*/
public function header($key, $value)
{
Expand All @@ -131,6 +132,17 @@ public function headerNoCache()
}
}

/**
* Remove HTTP header
*
* @param string $key (ex: "Content-Language")
* @return void
*/
public function headerRemove($key)
{
header_remove($key);
}

/**
* Data (string|array) to display JSON (with header content-type) and exit application
*
Expand Down
2 changes: 1 addition & 1 deletion app/vendor/Eco/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
/**
* Eco version
*/
const ECO_VERSION = '1.7.0';
const ECO_VERSION = '1.7.1';
3 changes: 2 additions & 1 deletion docs/response.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## Response Class
The Response class is used to access response methods:
- `cookieRemove($key, $path)` - remove cookie
- `cookieSet($name, $value, $expire, [...])` - set cookie
- `cookieSet($key, $value, $expire, [...])` - set cookie
- `header($key, $value)` - HTTP header setter
- `headerNoCache()` - send no cache headers
- `headerRemove($key)` - Remove HTTP header
- `json($data, $value)` - output JSON response with content-type header
- `redirect($location, $use_301)` - send redirect in response
- `statusCode($code)` - send HTTP response status code
Expand Down

0 comments on commit 400e9de

Please sign in to comment.