Permalink
Browse files

enabled redirectless 404

  • Loading branch information...
1 parent e892a4f commit 1b7936e8d3e9e982b963092ff13b68cae9be0612 @peterjanbrone committed Feb 15, 2012
Showing with 20 additions and 2 deletions.
  1. +16 −0 frontend/core/engine/navigation.php
  2. +4 −2 frontend/core/engine/page.php
View
16 frontend/core/engine/navigation.php
@@ -47,6 +47,21 @@ public function __construct()
}
/**
+ * Creates and renders a 404 page
+ */
+ public static function dieWith404()
+ {
+ // init new 404 page
+ $page = new FrontendPage(404);
+
+ // display the page
+ $page->display();
@janmoesen
janmoesen Feb 15, 2012

"Say why, not what."

All you are doing, is duplicating the code in comments, so whenever you need to change the code, you will need to change the comments too.

$page->display() is pretty unambiguous and does not require further explanation.

+
+ // prevent further execution
+ exit;
+ }
+
+ /**
* Creates a Backend URL for a given action and module
* If you don't specify a language the current language will be used.
*
@@ -540,6 +555,7 @@ public static function getURLForExtraId($id, $language = null)
return self::getURL(404, $language);
}
+
@janmoesen
janmoesen Feb 15, 2012

Whence the empty line?

/**
* This function lets you add ignored pages
*
View
6 frontend/core/engine/page.php
@@ -71,7 +71,7 @@ class FrontendPage extends FrontendBaseObject
*/
protected $statusCode = 200;
- public function __construct()
+ public function __construct($pageId = null)
@janmoesen
janmoesen Feb 15, 2012

You might want to add a comment to the function's docblock explaining what the optional $pageId parameter does, and what happens if it is not set.

{
parent::__construct();
@@ -82,7 +82,9 @@ public function __construct()
Spoon::set('page', $this);
// get pageId for requested URL
- $this->pageId = FrontendNavigation::getPageId(implode('/', $this->URL->getPages()));
+ $this->pageId = ($pageId === null)
+ ? FrontendNavigation::getPageId(implode('/', $this->URL->getPages()))
+ : (int) $pageId;
// set headers if this is a 404 page
if($this->pageId == 404) $this->statusCode = 404;

0 comments on commit 1b7936e

Please sign in to comment.