Ignore:
Timestamp:
08/22/10 19:35:26 (21 months ago)
Author:
vain
Message:
  • fix bugs on subcontroller recognition and enabled subcontroller dispatching
  • added method dispatchable() to test the routing, before dispatching
  • added method reset() to set default values to the TargetRoute? object
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/dispatcher.core.php

    r4578 r4597  
    2727    * @copyright  Jens-André Koch (2005-onwards) 
    2828    * @link       http://www.clansuite.com 
    29     *  
     29    * 
    3030    * @version    SVN: $Id$ 
    3131    */ 
     
    6161        $route = Clansuite_HttpRequest::getRoute(); 
    6262 
    63          #$event = Clansuite_EventDispatcher::instantiate(); 
     63        #$event = Clansuite_EventDispatcher::instantiate(); 
    6464        #$event->addEventHandler('onBeforeControllerMethodCall', new Clansuite_Event_InitializeModule()); 
    6565 
     
    6969        } 
    7070 
    71         $filename     = $route->getFilename(); 
    7271        $classname    = $route->getClassname(); 
    7372        $method       = $route->getMethod(); 
    7473        $parameters   = $route->getParameters(); 
    75         $request_meth = Clansuite_HttpRequest::getRequestMethod(); 
    76         $renderengine = $route->getRenderEngine(); 
     74        #$request_meth = Clansuite_HttpRequest::getRequestMethod(); 
     75        #$renderengine = $route->getRenderEngine(); 
    7776 
    7877        Clansuite_Debug::firebug($route); 
    7978        #unset($route); 
    8079 
    81         /** 
    82          * The file we want to call has to exists 
    83          */ 
    84         if(false === is_file($filename) ) 
    85         { 
    86             throw new Clansuite_Exception('File not found "' . $filename .'".'); 
    87         } 
    88         else 
    89         { 
    90             include $filename; 
    91         } 
     80        $controllerInstance = new $classname( 
     81                        Clansuite_CMS::getInjector()->instantiate('Clansuite_HttpRequest'), 
     82                        Clansuite_CMS::getInjector()->instantiate('Clansuite_HttpResponse') 
     83        ); 
    9284 
    93         /** 
    94          * Inside this file, the correct class has to exist 
    95          */ 
    96         if(true === class_exists($classname, false)) 
    97         { 
    98             # instantiate the module controller and pass request and response object to it 
    99             $controllerInstance = new $classname( 
    100                 Clansuite_CMS::getInjector()->instantiate('Clansuite_HttpRequest'), 
    101                 Clansuite_CMS::getInjector()->instantiate('Clansuite_HttpResponse') 
    102             ); 
    103         } 
    104         else 
    105         { 
    106             throw new Clansuite_Exception('There was no controller named "' . $classname . '".'); 
    107         } 
    108  
    109         /** 
    110          * Initialize the Module 
    111          */ 
     85        # Initialize the Module 
    11286        if(true === method_exists($controllerInstance, 'initializeModule')) 
    11387        { 
     
    11589        } 
    11690 
    117         # @todo fix wrong position 
    11891        Clansuite_Breadcrumb::initBreadcrumbs(); 
    11992 
    120         /** 
    121          * Handle Method 
    122          * 
    123          * 1) check if method exists in class (meaning the module file) -> CALL 
    124          * 2) check if method exists in module/actions path (command factory) -> CALL 
    125          * 3) if not found display error -> ERROR 
    126          */ 
     93        # Finally: dispatch to the requested controller method 
    12794        if(true === method_exists($controllerInstance, $method)) 
    12895        { 
    12996            $controllerInstance->$method($parameters); 
    13097        } 
    131         /* 
    132         elseif(is_file(ROOT_MOD . $modulename.'/controller/commands/'.$methodname.'.php') === true) 
    133         { 
    134             # command controller factory 
    135             # create command (by including the file of the actioncontroller) 
    136             # example: 'modulename/controller/commands/action_show.php' 
    137             return ROOT_MOD . $modulename.'/controller/commands/'.$methodname.'.php'; 
    138         }*/ 
    139         else # error 
    140         { 
    141             throw new Clansuite_Exception('There was no action named "' . $method . '".', 2); 
    142         } 
    14398    } 
    14499} 
Note: See TracChangeset for help on using the changeset viewer.