Skip to content

Commit

Permalink
Merge pull request #727 from LuckyCyborg/master
Browse files Browse the repository at this point in the history
Split the Core\Error Controller part to App\Controllers\Error
  • Loading branch information
daveismynamecom committed Apr 12, 2016
2 parents 7de8594 + 6c71ecf commit 3a6dd92
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 54 deletions.
1 change: 0 additions & 1 deletion app/Controllers/Demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/
class Demo extends Controller
{

/**
* Call the parent construct
*/
Expand Down
34 changes: 34 additions & 0 deletions app/Controllers/Error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
namespace App\Controllers;

use Core\Controller;
use Core\View;

/**
* Error controller to generate 404 pages.
*/
class Error extends Controller
{
/**
* Call the parent construct.
*/
public function __construct()
{
parent::__construct();
}

/**
* Load a 404 page with the Error message.
*/
public function index($error)
{
$data['title'] = '404';
$data['error'] = $error;

View::addHeader("HTTP/1.0 404 Not Found");

View::renderTemplate('header', $data);
View::render('Error/404', $data);
View::renderTemplate('footer', $data);
}
}
14 changes: 13 additions & 1 deletion app/Controllers/Language.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
<?php
namespace App\Controllers;

use Core\Controller;
use Core\Language as CoreLanguage;
use Helpers\Url;
use Helpers\Cookie;
use Helpers\Session;


class Language
class Language extends Controller
{
/**
* Call the parent construct.
*/
public function __construct()
{
parent::__construct();
}

/**
* Change the Framework Language.
*/
public function change($language)
{
// Only set language if it's in the Languages array
Expand Down
13 changes: 7 additions & 6 deletions app/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* @version 3.0
*/

/** Create alias for Router. */
use Core\Router;
use Helpers\Hooks;


/** Define static routes. */

// Default Routing
Expand All @@ -19,12 +19,13 @@

// The Framework's Language Changer.
Router::any('language/(:any)', 'App\Controllers\Language@change');
/** End default routes */
/** End default Routes */

/** Module routes. */
/** Module Routes. */
$hooks = Hooks::get();

$hooks->run('routes');
/** End Module routes. */
/** End Module Routes. */

/** If no route found. */
Router::error('Core\Error@index');
/** If no Route found. */
Router::error('App\Controllers\Error@index');
7 changes: 1 addition & 6 deletions app/Views/Error/404.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
<?php

use Core\Error;

?>
<div class="container content">
<div class="row">
<div class="col-md-12">

<h1>404</h1>

<?php echo $data['error'];?>
<?= $error; ?>

<hr />

Expand Down
42 changes: 3 additions & 39 deletions system/Core/Error.php
Original file line number Diff line number Diff line change
@@ -1,54 +1,18 @@
<?php
/**
* Error class - calls a 404 page.
* Error class.
*
* @author David Carr - [email protected]
* @version 3.0
*/

namespace Core;

use Core\Controller;
use Core\View;

/**
* Error class to generate 404 pages.
* Error class.
*/
class Error extends Controller
class Error
{
/**
* $error holder.
*
* @var string
*/
private $error = null;

/**
* Save error to $this->error.
*
* @param string $error
*/
public function __construct($error = null)
{
parent::__construct();
$this->error = $error;
}

/**
* Load a 404 page with the error message.
*/
public function index($error = null)
{
header("HTTP/1.0 404 Not Found");

$data['title'] = '404';
$data['error'] = $error ? $error : $this->error;

View::renderTemplate('header', $data);
View::render('Error/404', $data);
View::renderTemplate('footer', $data);
}

/**
* Display errors.
*
Expand Down
2 changes: 1 addition & 1 deletion system/Core/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Router
*
* @var null $errorCallback
*/
private $errorCallback = '\Core\Error@index';
private $errorCallback = '\App\Controllers\Error@index';


/**
Expand Down

0 comments on commit 3a6dd92

Please sign in to comment.