[NFR] Router: need hostname for notFound()
How about adding a new parameter "hostname" in notFound()? For example, I want to provide different error pages for different hostnames.
For now I use a dirty hook like this:
class MyRouter extends \Phalcon\Mvc\Router
{
// New function for passing array of actions descriptions
public function setNotFoundRoutes($routes)
{
RoutingHookNotFoundController::$r = $routes;
// Using default notFound() to hook NotFound event
$this->notFound([
'controller' => 'RoutingHookNotFound',
'action' => 'notFound',
]);
}
}
class RoutingHookNotFoundController extends \Phalcon\Mvc\Controller
{
public static $r;
public function notFoundAction()
{
$hostname = $this->request->getHttpHost();
// Select relevant action for current hostname
if (!empty(self::$r)) {
if (isset(self::$r[$hostname])) {
return $this->dispatcher->forward(self::$r[$hostname]);
} else {
return $this->dispatcher->forward(self::$r[0]);
}
}
}
}
I can see the usefulness of passing parameters to the handler, but I can't see it for adding a specific 'hostname' parameter that only solves a specific problem that can be easily avoided in several ways.
Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues