Show
Ignore:
Timestamp:
06/24/08 12:34:17 (7 months ago)
Author:
david
Message:

AgaviController::dispatch() now accepts module and action names in the request data argument, partially already implemented in [2528] for #777, but now all is fine and consistent. Still doesn't allow overwriting of module and action parameters with routing enabled, mind you. Closes #776 and #777

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/src/controller/AgaviController.class.php

    r2528 r2534  
    163163    try { 
    164164       
     165      $rq = $this->context->getRequest(); 
     166      $rd = $rq->getRequestData(); 
     167       
    165168      // match routes and assign returned initial execution container 
    166169      $container = $this->context->getRouting()->execute(); 
    167170       
    168171      // merge in any arguments given. they need to have precedence over what the routing found 
    169       $requestData = $this->context->getRequest()->getRequestData(); 
    170172      if($arguments !== null) { 
    171         $requestData->merge($arguments); 
     173        $rd->merge($arguments); 
    172174      } 
    173175       
     176      // next, we have to see if the routing did anything useful, i.e. whether or not it was enabled. 
    174177      $moduleName = $container->getModuleName(); 
    175178      $actionName = $container->getActionName(); 
    176        
    177       if($moduleName == null) { 
    178         // no module has been specified 
    179         $container->setModuleName(AgaviConfig::get('actions.default_module')); 
    180         $container->setActionName(AgaviConfig::get('actions.default_action')); 
     179      if(!$moduleName) { 
     180        // no module has been specified; that means the routing did not run, as it would otherwise have the 404 action's module name 
     181         
     182        // lets see if our request data has values for module and action 
     183        $ma = $rq->getParameter('module_accessor'); 
     184        $aa = $rq->getParameter('action_accessor'); 
     185        if($rd->hasParameter($ma) && $rd->hasParameter($aa)) { 
     186          // yup. grab those 
     187          $moduleName = $rd->getParameter($ma); 
     188          $actionName = $rd->getParameter($aa); 
     189        } else { 
     190          // nope. then its time for the default action 
     191          $moduleName = AgaviConfig::get('actions.default_module'); 
     192          $actionName = AgaviConfig::get('actions.default_action'); 
     193        } 
     194         
     195        // so by now we hopefully have something reasonable for module and action names - let's set them on the container 
     196        $container->setModuleName($moduleName); 
     197        $container->setActionName($actionName); 
    181198      } 
    182199