Changeset 2534

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

Location:
branches/0.11
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/CHANGELOG

    r2533 r2534  
    1212ADD: Allow nested routing structures with concatenated name or action attributes in ancestors other than immediate parents (Dominik) (#764) 
    1313 
     14CHG: AgaviController::dispatch() should accept module and action names in the request data argument with routing disabled (#776) (David) 
    1415CHG: Routing should not just bail out of execute() if routing is enabled, but no routes are defined (#779) (David) 
    1516CHG: Refactor AgaviContext::initialize() and the passing of "profile" (#778) (David) 
  • 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       
  • branches/0.11/src/routing/AgaviRouting.class.php

    r2531 r2534  
    677677 
    678678    if(!AgaviConfig::get('core.use_routing', false)) { 
    679       // routing disabled, determine module and action manually and bail out 
    680       $container->setModuleName($reqData->getParameter($req->getParameter('module_accessor'))); 
    681       $container->setActionName($reqData->getParameter($req->getParameter('action_accessor'))); 
    682  
     679      // routing disabled, just bail out here 
    683680      return $container; 
    684681    }