SitePoint Sponsor

User Tag List

Page 5 of 5 FirstFirst 12345
Results 101 to 104 of 104
  1. #101
    SitePoint Guru
    Join Date
    Nov 2003
    Location
    Huntsville AL
    Posts
    706
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    I like one action per file. Keeps the file size down. I also define two methods, execute() and executePost() with the dispatcher deciding between the two based on request type.

  2. #102
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would go with having multiple actions on the same controller, as it reduces the complexity on the file system overall; Having individual files in a bid to reduce file size on INCLUDEs makes little difference, as the overhead otherwise is not here nor there in real terms.

  3. #103
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston View Post
    I would go with having multiple actions on the same controller, as it reduces the complexity on the file system overall; Having individual files in a bid to reduce file size on INCLUDEs makes little difference, as the overhead otherwise is not here nor there in real terms.
    You mean something like this:

    PHP Code:
    <?php
    class FrontController {
        var 
    $directory;
        var 
    $default;
        var 
    $error;
        var 
    $pre_action = array();
        
        function 
    __construct(&$locator) {
            
    $this->locator =& $locator;
        }
        
        function 
    setDirectory($directory) {
            
    $this->directory $directory;
        }
        
        function 
    setDefault(&$action) {
            
    $this->default =& $action;
        }
        
        function 
    setError(&$action) {
            
    $this->error =& $action;
        }
        
        function 
    addPreMethod($key, &$value) {
            
    $this->pre_method[$key] =& $value;
        }
        
        function 
    dispatch($action) {
            while (
    $action) {
                
    $controller $action->getClass();
                
    $method     $action->getMethod();
                
                
    $action NULL;
                
                if (
    $controller) {
                    foreach (
    array_keys($this->pre_method) as $pre_method) {
                        if (
    method_exists($controller$pre_method)) {
                            
    $result $controller->dispatch($pre_method);
                            
                            if (
    $result) {
                                if (
    is_object($result)) {
                                    
    $action $result;
                                } elseif (
    is_object($this->pre_method[$pre_method])) {
                                    
    $action $this->pre_method[$pre_method];
                                } else {
                                    
    $action $this->error;
                                }
                                
                                continue 
    2;
                            }
                        }
                    }
                    
                    if (
    method_exists($controller$method)) {
                        
    $action $controller->dispatch($method);
                    }
                } else {
                    
    $action $this->error;
                }    
            }
        }    
    }
    ?>

  4. #104
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    this thread is now closed

    sorry, folks, it was causing too much turmoil and ill will
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •