Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Commit

Permalink
Cleaned up Zepto\Route\ErrorRoute
Browse files Browse the repository at this point in the history
  • Loading branch information
hassankhan committed Feb 19, 2014
1 parent 0e1cee5 commit 054a2ca
Showing 1 changed file with 7 additions and 31 deletions.
38 changes: 7 additions & 31 deletions library/Zepto/Route/ErrorRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
/**
* ErrorRoute
*
* This route is executed on any application error.
*
* @package Zepto
* @subpackage Route
* @author Hassan Khan <contact@hassankhan.me>
* @link https://github.com/hassankhan/Zepto
* @license MIT
* @since 0.7
*/
class ErrorRoute
class ErrorRoute extends \Zepto\Route
{

/**
Expand All @@ -22,38 +24,12 @@ class ErrorRoute
* @param string $url
* @codeCoverageIgnore
*/
public function __construct($url = '')
public function __construct($url = '', $title, $body)
{
$callback = function () use ($this) {
return $this->generate_error_template('')
$callback = function() use ($title, $body) {
return sprintf('<html><head><title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:65px;}</style></head><body><h1>%s</h1><p>%s</p></body></html>', $title, $title, $body);
};
parent::__construct($url, $callback);
}

/**
* Executes a route's callback and returns the result. Simple as that.
*
* @param array $params
* @return string
*/
public function execute($params = array())
{
return call_user_func_array($this->callback, $params);
}

/**
* ACCESSORS
*/

/**
* Returns a standard template for error messages. Thanks, Slim
*
* @param string $title
* @param string $body
* @return string
* @codeCoverageIgnore
*/
protected function generate_error_template($title, $body)
{
return sprintf('<html><head><title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:65px;}</style></head><body><h1>%s</h1><p>%s</p></body></html>', $title, $title, $body);
}
}

0 comments on commit 054a2ca

Please sign in to comment.