diff --git a/lib/ServiceLocator.php b/lib/ServiceLocator.php index 364893f97..d23aee587 100644 --- a/lib/ServiceLocator.php +++ b/lib/ServiceLocator.php @@ -32,7 +32,7 @@ final class ServiceLocator extends Base parent::__construct(); } - function get($id) + function get($id, $default = 'throws an exception') { if (isset($this->_entries[$id]) || array_key_exists($id, $this->_entries)) @@ -60,7 +60,13 @@ final class ServiceLocator extends Base return new $id; } - throw new Exception('no such entry: '.$id); + // Nothing found. + if (func_num_args() < 2) + { + throw new Exception('no such entry ('.$path.')'); + } + + return $default; } function set($id, $value) @@ -186,7 +192,7 @@ final class ServiceLocator extends Base 'url' => array($tu, 'url'), ); $tm->defaultVariables += array( - 'base_path' => $this->get('config')['base_path'].'/', + 'base_path' => $this->get('config')['base_path'], ); return $tm; diff --git a/public/img/favicon.ico.png b/public/img/favicon.png similarity index 100% rename from public/img/favicon.ico.png rename to public/img/favicon.png diff --git a/public/index.php b/public/index.php index f03d1ae76..02153d1ab 100644 --- a/public/index.php +++ b/public/index.php @@ -75,10 +75,11 @@ $routes = $locator->get('routes'); $parameters = $routes->match($context); // Basic error message if no route found. -if (!$parameters) +if (!$parameters + || !($controller = $locator->get('controller.'.$parameters['controller'], false))) { trigger_error( - 'no route found', + 'no route found for: '.$context['path'], E_USER_ERROR ); } @@ -86,8 +87,5 @@ if (!$parameters) // @todo Not sure it is the right place to put the current route. $locator->set('current_controller', $parameters['controller']); -// Gets the current controller. -$controller = $locator->get('controller.'.$parameters['controller']); - // Dispatches the current action. $controller->dispatch($parameters['action']); diff --git a/views/_base.templet b/views/_base.templet index 73cb2c26d..533ec6b23 100644 --- a/views/_base.templet +++ b/views/_base.templet @@ -33,19 +33,17 @@
- - -