Skip to content

Commit

Permalink
fixes for router - 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jakoch committed Sep 8, 2012
1 parent 4b6f031 commit f2250e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion framework/Koch/Mvc/Mapper.php
Expand Up @@ -36,7 +36,7 @@
* @package Core
* @subpackage Mapper
*/
class Mapper extends \ArrayObject
class Mapper #extends \ArrayObject
{
/* @const string Classname prefix for modules = Namespace */
const MODULE_NAMESPACE = 'Clansuite\Modules';
Expand Down
3 changes: 2 additions & 1 deletion framework/Koch/Router/Router.php
Expand Up @@ -881,8 +881,9 @@ public function loadDefaultRoutes()
$this->addRoute('/:module/(:id)', array(1 => 'id')); // "/news/news/31" (show/update/delete)
$this->addRoute('/:module/:action'); // "/news/new" (new)
$this->addRoute('/:module/:controller'); // "/news/news" (list)
$this->addRoute('/:controller/:action/(:id)', array(2 => 'id')); // "/news/edit/42" (edit)
# three segments
$this->addRoute('/:controller/:action/(:id)', array(2 => 'id')); // "/news/edit/42" (edit)
$this->addRoute('/:module/(:id)/:action', array(1 => 'id')); // "/news/42/edit" (edit)
$this->addRoute('/:module/:controller/(:id)', array(2 => 'id')); // "/news/news/31" (show/update/delete)
$this->addRoute('/:module/:controller/:action'); // "/news/news/new" (new)
# four segments
Expand Down
23 changes: 11 additions & 12 deletions framework/Koch/Router/TargetRoute.php
Expand Up @@ -179,15 +179,10 @@ public static function setMethod($method)
}

public static function getMethod()
{
// check if method is correctly prefixed with 'action_'
if (self::$parameters['method'] !== null and mb_strpos(self::$parameters['method'], 'action_')) {
return self::$parameters['method'];
} else {
// add method prefix (action_)
$method = self::mapActionToMethodname(self::getAction());
self::setMethod($method);
}
{
// add method prefix (action_)
$method = self::mapActionToMethodname(self::getAction());
self::setMethod($method);

return self::$parameters['method'];
}
Expand Down Expand Up @@ -285,7 +280,7 @@ public static function dispatchable()
// was the class loaded before?
if (false === class_exists($classname, false)) {
// loading manually
if (is_file($filename)) {
if (is_file($filename) === true) {
include_once $filename;
// @todo position for log command
echo 'Loaded Controller: ' . $filename;
Expand Down Expand Up @@ -338,14 +333,18 @@ public static function setSegmentsToTargetRoute($array)
if (isset($array['module']) === true) {
self::setModule($array['module']);
// yes, set the controller of the module, too
// if it is not News to NewsController, then it will be overwritten below
// if it is e.g. AdminController on Module News, then it will be overwritten below
self::setController($array['module']);
unset($array['module']);
}

// Controller
if (isset($array['controller']) === true) {
self::setController($array['controller']);
// if a module was not set yet, then set the current controller also as module
if(self::$parameters['module'] === 'index') {
self::setModule($array['controller']);
}
unset($array['controller']);
}

Expand All @@ -360,7 +359,7 @@ public static function setSegmentsToTargetRoute($array)
self::setId($array['id']);
// if we set an id, and action is empty then [news/id] was requested
// we fill automatically in the action show
if(self::$parameters['action'] == 'list') { self::setAction('show'); }
if(self::$parameters['action'] === 'list') { self::setAction('show'); }
unset($array['id']);
}

Expand Down

0 comments on commit f2250e6

Please sign in to comment.