Changeset 1811

Show
Ignore:
Timestamp:
03/01/07 19:28:41 (23 months ago)
Author:
david
Message:

ability to prevent sending of the response in Controller::dispatch() which now also returns the final response (not the global one, mind you, but that one gets merged in) via parameter 'send_response'. plus some small refactorings. closes #469

Files:
1 modified

Legend:

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

    r1713 r1811  
    3030 * @version    $Id$ 
    3131 */ 
    32 class AgaviController 
     32class AgaviController extends AgaviParameterHolder 
    3333{ 
    3434  /** 
     
    3636   */ 
    3737  protected $numExecutions = 0; 
    38    
    39   /** 
    40    * @var        int The maximum number of execution container runs allowed. 
    41    */ 
    42   protected $maxExecutions = 20; 
    4338   
    4439  /** 
     
    109104  public function countExecution() 
    110105  { 
    111     if(++$this->numExecutions > $this->maxExecutions && $this->maxExecutions > 0) { 
     106    $maxExecutions = $this->getParameter('max_executions'); 
     107     
     108    if(++$this->numExecutions > $maxExecutions && $maxExecutions > 0) { 
    112109      throw new AgaviControllerException('Too many execution runs have been detected for this Context.'); 
    113110    } 
     
    190187      $response = $container->getResponse(); 
    191188      $response->merge($this->response); 
    192       $response->send($container->getOutputType()); 
     189       
     190      if($this->getParameter('send_response')) { 
     191        $response->send($container->getOutputType()); 
     192      } 
     193       
     194      return $response; 
    193195       
    194196    } catch(Exception $e) { 
     
    326328 
    327329  /** 
     330   * Constructor. 
     331   * 
     332   * @author     David Zülke <dz@bitxtender.com> 
     333   * @since      0.11.0 
     334   */ 
     335  public function __construct() 
     336  { 
     337    parent::__construct(); 
     338    $this->setParameters(array( 
     339      'max_executions' => 20, 
     340      'send_response' => true, 
     341    )); 
     342  } 
     343   
     344  /** 
    328345   * Initialize this controller. 
    329346   * 
     
    337354  { 
    338355    $this->context = $context; 
     356     
     357    $this->setParameters($parameters); 
    339358     
    340359    $rfi = $context->getFactoryInfo('response'); 
    341360    $this->response = new $rfi["class"]();  
    342361    $this->response->initialize($context, $rfi["parameters"]); 
    343      
    344     $this->maxExecutions = isset($parameters['max_executions']) ? $parameters['max_executions'] : 20; 
    345362     
    346363    $cfg = AgaviConfig::get('core.config_dir') . '/output_types.xml';