Changeset 1494

Show
Ignore:
Timestamp:
01/13/07 19:32:37 (2 years ago)
Author:
david
Message:

more execution flow refactoring: removed merge/export/import/lock nonsense from responses. execution containers can now be created with an output type, forwards done now by returning an array from the view instead of an exec container (not sure if we'll keep that). slots and global response stuff todo. refs #373

Location:
branches/david-execution_flow/src
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • branches/david-execution_flow/src/controller/AgaviController.class.php

    r1477 r1494  
    119119   * @param      string The name of the action. 
    120120   * @param      array  Optional additional parameters. 
     121   * @param      string The name of the initial output type to set. 
    121122   * 
    122123   * @return     AgaviExecutionContainer A new execution container instance, 
     
    126127   * @since      0.11.0 
    127128   */ 
    128   public function createExecutionContainer($moduleName = null, $actionName = null, array $parameters = array()) 
     129  public function createExecutionContainer($moduleName = null, $actionName = null, array $parameters = array(), AgaviOutputType $outputType = null) 
    129130  { 
    130131    // create a new filter chain 
     
    135136    $container->setActionName($actionName); 
    136137    $container->setParameters($parameters); 
     138    $container->setOutputType($outputType === null ? $this->context->getController()->getOutputType() : $outputType); 
    137139    return $container; 
    138140  } 
  • branches/david-execution_flow/src/controller/AgaviExecutionContainer.class.php

    r1477 r1494  
    9898    $this->response = new $rfi['class']; 
    9999    $this->response->initialize($this->context, $rfi['parameters']); 
    100      
    101     $this->outputType = $context->getController()->getOutputType(); 
    102100  } 
    103101   
  • branches/david-execution_flow/src/filter/AgaviExecutionFilter.class.php

    r1489 r1494  
    366366        $request->toggleLock($key); 
    367367         
    368         if($next instanceof AgaviExecutionContainer) { 
    369           $container->setNext($next); 
     368        if(is_array($next) && count($next) >= 2) { 
     369          $container->setNext($controller->createExecutionContainer($next[0], $next[1], isset($next[2]) ? $next[2] : array(), isset($next[3]) ? ($next[3] instanceof AgaviOutputType ? $next[3] : $controller->getOutputType($next[3])) : $container->getOutputType())); 
    370370        } else { 
    371371          $attributes =& $viewInstance->getAttributes(); 
  • branches/david-execution_flow/src/response/AgaviResponse.class.php

    r1239 r1494  
    7272   
    7373  /** 
    74    * Export the contents of this response. 
    75    * 
    76    * @return     array An array of data. 
    77    * 
    78    * @author     David Zuelke <du@bitxtender.com> 
    79    * @since      0.11.0 
    80    */ 
    81   public function export() 
    82   { 
    83     return array('content' => $this->getContent(), 'locked' => $this->isLocked()); 
    84   } 
    85    
    86   /** 
    87    * Export the information data (e.g. HTTP Headers, Cookies) for this response. 
    88    * 
    89    * @return     array An array of data. 
    90    * 
    91    * @author     David Zuelke <dz@bitxtender.com> 
    92    * @since      0.11.0 
    93    */ 
    94   public function exportInfo() 
    95   { 
    96     return array('locked' => $this->isLocked()); 
    97   } 
    98    
    99   /** 
    100    * Import data for this response. 
    101    * 
    102    * @param      array An array of data. 
    103    * 
    104    * @return     bool Whether or not the operation was successful. 
    105    * 
    106    * @author     David Zuelke <dz@bitxtender.com> 
    107    * @since      0.11.0 
    108    */ 
    109   public function import(array $data) 
    110   { 
    111     $retval = true; 
    112     if(isset($data['content'])) { 
    113       $retval = $this->setContent($data['content']); 
    114     } 
    115     if(isset($data['locked']) && $data['locked']) { 
    116       $this->lock(); 
    117     } 
    118     return $retval; 
    119   } 
    120    
    121   /** 
    122    * Merge in data for this response. 
    123    * 
    124    * @param      array An array of data. 
    125    * 
    126    * @return     bool Whether or not the operation was successful. 
    127    * 
    128    * @author     David Zuelke <dz@bitxtender.com> 
    129    * @since      0.11.0 
    130    */ 
    131   public function merge(array $data) 
    132   { 
    133     // do not lock the response even if $data has locked=true! 
    134      
    135     if(isset($data['content'])) { 
    136       return $this->appendContent($data['content']); 
    137     } 
    138     return true; 
    139   } 
    140    
    141   /** 
    142    * Append data to this response. 
    143    * 
    144    * @param      array An array of data. 
    145    * 
    146    * @return     bool Whether or not the operation was successful. 
    147    * 
    148    * @author     David Zuelke <dz@bitxtender.com> 
    149    * @since      0.11.0 
    150    */ 
    151   public function append(array $data) 
    152   { 
    153     // do not lock the response even if $data has locked=true! 
    154      
    155     if(isset($data['content'])) { 
    156       return $this->appendContent($data['content']); 
    157     } 
    158     return true; 
    159   } 
    160    
    161   /** 
    162    * Check if this Response is locked, i.e. whether or not new content and other 
    163    * output information can be set. 
    164    * 
    165    * @return     bool Whether the response is locked. 
    166    * 
    167    * @author     David Zuelke <dz@bitxtender.com> 
    168    * @since      0.11.0 
    169    */ 
    170   public function isLocked() 
    171   { 
    172     return $this->locked; 
    173   } 
    174    
    175   /** 
    176    * Lock this Response so that it does not accept any modifications. 
    177    * 
    178    * @author     David Zuelke <dz@bitxtender.com> 
    179    * @since      0.11.0 
    180    */ 
    181   public function lock() 
    182   { 
    183     $this->locked = true; 
    184   } 
    185    
    186   /** 
    18774   * Retrieve the content set for this Response 
    18875   * 
     
    20996  public function setContent($content) 
    21097  { 
    211     if(!$this->locked) { 
    212       $this->content = $content; 
    213       return true; 
    214     } 
    215     return false; 
     98    $this->content = $content; 
     99    return true; 
    216100  } 
    217101   
     
    256140  public function clearContent() 
    257141  { 
    258     if(!$this->locked) { 
    259       $this->content = ''; 
    260       return true; 
    261     } 
    262     return false; 
     142    $this->content = ''; 
     143    return true; 
    263144  } 
    264145   
  • branches/david-execution_flow/src/response/AgaviWebResponse.class.php

    r1475 r1494  
    136136  public function clear() 
    137137  { 
    138     if(!$this->locked) { 
    139       $this->clearContent(); 
    140       $this->httpHeaders = array(); 
    141       $this->cookies = array(); 
    142     } 
    143   } 
    144    
    145   /** 
    146    * Export the contents of this response. 
    147    * 
    148    * @return     array An array of data. 
    149    * 
    150    * @author     David Zuelke <du@bitxtender.com> 
    151    * @since      0.11.0 
    152    */ 
    153   public function export() 
    154   { 
    155     return array_merge(parent::export(), array('httpStatusCode' => $this->getHttpStatusCode(), 'httpHeaders' => $this->getHttpHeaders(), 'cookies' => $this->cookies)); 
    156   } 
    157    
    158   /** 
    159    * Export the information data (e.g. HTTP Headers, Cookies) for this response. 
    160    * 
    161    * @return     array An array of data. 
    162    * 
    163    * @author     David Zuelke <dz@bitxtender.com> 
    164    * @since      0.11.0 
    165    */ 
    166   public function exportInfo() 
    167   { 
    168     return array_merge(parent::exportInfo(), array('httpStatusCode' => $this->getHttpStatusCode(), 'httpHeaders' => $this->getHttpHeaders(), 'cookies' => $this->cookies)); 
    169   } 
    170    
    171   /** 
    172    * Import data for this response. 
    173    * 
    174    * @param      array An array of data. 
    175    * 
    176    * @return     bool Whether or not the operation was successful. 
    177    * 
    178    * @author     David Zuelke <dz@bitxtender.com> 
    179    * @since      0.11.0 
    180    */ 
    181   public function import(array $data) 
    182   { 
    183     if(!$this->locked) { 
    184       if(isset($data['httpStatusCode'])) { 
    185         $this->httpStatusCode = $data['httpStatusCode']; 
    186       } 
    187       if(isset($data['httpHeaders'])) { 
    188         $this->httpHeaders = $data['httpHeaders']; 
    189       } 
    190       if(isset($data['cookies'])) { 
    191         $this->cookies = $data['cookies']; 
    192       } 
    193       return parent::import($data) && true; 
    194     } 
    195     parent::import($data); 
    196     return false; 
    197   } 
    198    
    199   /** 
    200    * Merge in data for this response. 
    201    * 
    202    * @param      array An array of data. 
    203    * 
    204    * @return     bool Whether or not the operation was successful. 
    205    * 
    206    * @author     David Zuelke <dz@bitxtender.com> 
    207    * @since      0.11.0 
    208    */ 
    209   public function merge(array $data) 
    210   { 
    211     $retval = parent::merge($data); 
    212     if(!$this->locked) { 
    213       if(isset($data['cookies'])) { 
    214         $this->cookies = array_merge($data['cookies'], $this->cookies); 
    215       } 
    216       return $retval && true; 
    217     } 
    218     return $retval && false; 
    219   } 
    220    
    221   /** 
    222    * Append data to this response. 
    223    * 
    224    * @param      array An array of data. 
    225    * 
    226    * @return     bool Whether or not the operation was successful. 
    227    * 
    228    * @author     David Zuelke <dz@bitxtender.com> 
    229    * @since      0.11.0 
    230    */ 
    231   public function append(array $data) 
    232   { 
    233     $retval = parent::append($data); 
    234     if(!$this->locked) { 
    235       if(isset($data['httpStatusCode'])) { 
    236         $this->httpStatusCode = $data['httpStatusCode']; 
    237       } 
    238       if(isset($data['httpHeaders'])) { 
    239         $this->httpHeaders = array_merge($this->httpHeaders, $data['httpHeaders']); 
    240       } 
    241       if(isset($data['cookies'])) { 
    242         $this->cookies = array_merge($this->cookies, $data['cookies']); 
    243       } 
    244       return $retval && true; 
    245     } 
    246     return $retval && false; 
     138    $this->clearContent(); 
     139    $this->httpHeaders = array(); 
     140    $this->cookies = array(); 
    247141  } 
    248142   
  • branches/david-execution_flow/src/response/AgaviXmlrpcepiphpResponse.class.php

    r1239 r1494  
    9191  public function clearContent() 
    9292  { 
    93     if(!$this->locked) { 
    94       $this->content = array(); 
    95       return true; 
    96     } 
    97     return false; 
     93    $this->content = array(); 
     94    return true; 
    9895  } 
    9996   
     
    126123  public function clear() 
    127124  { 
    128     if(!$this->locked) { 
    129       $this->clearContent(); 
    130       $this->httpHeaders = array(); 
    131       $this->cookies = array(); 
    132     } 
     125    $this->clearContent(); 
     126    $this->httpHeaders = array(); 
     127    $this->cookies = array(); 
    133128  } 
    134129}