Development

Changeset 6662

You must first sign up to be able to contribute.

Changeset 6662

Show
Ignore:
Timestamp:
12/21/07 08:22:20 (2 years ago)
Author:
fabien
Message:

moved 404 management from response to controller, removed sfConfig dependency from response sub-framework

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/config/sfFactoryConfigHandler.class.php

    r6661 r6662  
    106106 
    107107        case 'response': 
     108          $parameters = array_merge(array('charset' => sfConfig::get('sf_charset'), 'logging' => sfConfig::get('sf_logging_enabled')), is_array($parameters) ? $parameters : array()); 
    108109          $instances[] = sprintf("  \$class = sfConfig::get('sf_factory_response', '%s');\n  \$this->factories['response'] = new \$class(\$this->dispatcher, sfConfig::get('sf_factory_response_parameters', %s));", $class, var_export($parameters, true)); 
    109110 
  • branches/1.1/lib/controller/sfController.class.php

    r6499 r6662  
    251251      $this->context->getEventDispatcher()->notify(new sfEvent($this, 'controller.change_action', array('module' => $moduleName, 'action' => $actionName))); 
    252252 
     253      if ($moduleName == sfConfig::get('sf_error_404_module') && $actionName == sfConfig::get('sf_error_404_action')) 
     254      { 
     255        $this->context->getResponse()->setStatusCode(404); 
     256        $this->context->getResponse()->setHttpHeader('Status', '404 Not Found'); 
     257 
     258        $this->dispatcher->notify(new sfEvent($this, 'controller.page_not_found', array('module' => $moduleName, 'action' => $actionName))); 
     259      } 
     260 
    253261      // process the filter chain 
    254262      $filterChain->execute(); 
  • branches/1.1/lib/response/sfResponse.class.php

    r6509 r6662  
    8181    $content = $event->getReturnValue(); 
    8282 
    83     if (sfConfig::get('sf_logging_enabled')) 
     83    if ($this->getParameter('logging')) 
    8484    { 
    8585      $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Send content (%s o)', strlen($content))))); 
  • branches/1.1/lib/response/sfWebResponse.class.php

    r6650 r6662  
    4747  { 
    4848    parent::initialize($dispatcher, $parameters); 
    49  
    50     $this->dispatcher->connect('controller.change_action', array($this, 'listenToChangeActionEvent')); 
    5149 
    5250    $this->statusTexts = array( 
     
    251249    if (false === stripos($value, 'charset')) 
    252250    { 
    253       $value .= '; charset='.sfConfig::get('sf_charset'); 
     251      $value .= '; charset='.$this->getParameter('charset'); 
    254252    } 
    255253 
     
    264262  public function getContentType() 
    265263  { 
    266     return $this->getHttpHeader('Content-Type', 'text/html; charset='.sfConfig::get('sf_charset')); 
     264    return $this->getHttpHeader('Content-Type', 'text/html; charset='.$this->getParameter('charset')); 
    267265  } 
    268266 
     
    282280    header($status); 
    283281 
    284     if (sfConfig::get('sf_logging_enabled')) 
     282    if ($this->getParameter('logging')) 
    285283    { 
    286284      $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Send status "%s"', $status)))); 
     
    292290      header($name.': '.$value); 
    293291 
    294       if ($value != '' && sfConfig::get('sf_logging_enabled')) 
     292      if ($value != '' && $this->getParameter('logging')) 
    295293      { 
    296294        $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Send header "%s": "%s"', $name, $value)))); 
     
    310308      } 
    311309 
    312       if (sfConfig::get('sf_logging_enabled')) 
     310      if ($this->getParameter('logging')) 
    313311      { 
    314312        $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Send cookie "%s": "%s"', $cookie['name'], $cookie['value'])))); 
     
    508506    if ($escape) 
    509507    { 
    510       $value = htmlentities($value, ENT_QUOTES, sfConfig::get('sf_charset')); 
     508      $value = htmlentities($value, ENT_QUOTES, $this->getParameter('charset')); 
    511509    } 
    512510 
     
    699697    list($this->content, $this->statusCode, $this->statusText, $this->parameterHolder, $this->cookies, $this->headerOnly, $this->headers, $this->metas, $this->httpMetas, $this->stylesheets, $this->javascripts, $this->slots) = $data; 
    700698  } 
    701  
    702   /** 
    703    * Listens to the controller.change_action event. 
    704    * 
    705    * @param sfEvent An sfEvent instance 
    706    * 
    707    */ 
    708   public function listenToChangeActionEvent(sfEvent $event) 
    709   { 
    710     $moduleName = $event['module']; 
    711     $actionName = $event['action']; 
    712  
    713     if ($moduleName == sfConfig::get('sf_error_404_module') && $actionName == sfConfig::get('sf_error_404_action')) 
    714     { 
    715       $this->setStatusCode(404); 
    716       $this->setHttpHeader('Status', '404 Not Found'); 
    717  
    718       $this->dispatcher->notify(new sfEvent($this, 'controller.page_not_found', array('module' => $moduleName, 'action' => $actionName))); 
    719     } 
    720   } 
    721699} 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.