Development

Changeset 9477

You must first sign up to be able to contribute.

Changeset 9477

Show
Ignore:
Timestamp:
06/09/08 11:41:14 (2 years ago)
Author:
fabien
Message:

refactored renderPartial() and renderComponent() in sfAction (code has been splitted to create a getPartial() and a getComponent() method)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/action/sfAction.class.php

    r9044 r9477  
    257257 
    258258  /** 
    259    * Appends the result of the given partial execution to the response content 
    260    * and bypasses the built-in view system. 
     259   * Returns the partial rendered content. 
    261260   * 
    262261   * If the vars parameter is omitted, the action's internal variables 
     
    266265   * available in the partial. 
    267266   * 
    268    * This method must be called as with a return: 
    269    * 
    270    * <code>return $this->renderPartial('foo/bar')</code> 
    271    * 
    272267   * @param  string $templateName partial name 
    273268   * @param  array  $vars         vars 
    274269   * 
     270   * @return string The partial content 
     271   */ 
     272  public function getPartial($templateName, $vars = null) 
     273  { 
     274    sfLoader::loadHelpers('Partial'); 
     275 
     276    $vars = !is_null($vars) ? $vars : $this->varHolder->getAll(); 
     277 
     278    return get_partial($templateName, $vars); 
     279  } 
     280 
     281  /** 
     282   * Appends the result of the given partial execution to the response content. 
     283   * 
     284   * This method must be called as with a return: 
     285   * 
     286   * <code>return $this->renderPartial('foo/bar')</code> 
     287   * 
     288   * @param  string $templateName partial name 
     289   * @param  array  $vars         vars 
     290   * 
    275291   * @return sfView::NONE 
     292   * 
     293   * @see    getPartial 
    276294   */ 
    277295  public function renderPartial($templateName, $vars = null) 
    278296  { 
    279     sfLoader::loadHelpers('Partial'); 
    280  
    281     $vars = !is_null($vars) ? $vars : $this->varHolder->getAll(); 
    282  
    283     return $this->renderText(get_partial($templateName, $vars)); 
    284   } 
    285  
    286   /** 
    287    * Appends the result of the given component execution to the response content 
    288    * and bypasses the built-in view system. 
     297    return $this->renderText($this->getPartial($templateName, $vars)); 
     298  } 
     299 
     300  /** 
     301   * Returns the component rendered content. 
    289302   * 
    290303   * If the vars parameter is omitted, the action's internal variables 
     
    293306   * If the vars parameter is set then only those values are 
    294307   * available in the component. 
    295    * 
    296    * This method must be called as with a return: 
    297    * 
    298    * <code>return $this->renderComponent('foo', 'bar')</code> 
    299308   * 
    300309   * @param  string  $moduleName    module name 
     
    302311   * @param  array   $vars          vars 
    303312   * 
     313   * @return string  The component rendered content 
     314   */ 
     315  public function getComponent($moduleName, $componentName, $vars = null) 
     316  { 
     317    sfLoader::loadHelpers('Partial'); 
     318 
     319    $vars = !is_null($vars) ? $vars : $this->varHolder->getAll(); 
     320 
     321    return get_component($moduleName, $componentName, $vars); 
     322  } 
     323 
     324  /** 
     325   * Appends the result of the given component execution to the response content. 
     326   * 
     327   * This method must be called as with a return: 
     328   * 
     329   * <code>return $this->renderComponent('foo', 'bar')</code> 
     330   * 
     331   * @param  string  $moduleName    module name 
     332   * @param  string  $componentNae  component name 
     333   * @param  array   $vars          vars 
     334   * 
    304335   * @return sfView::NONE 
     336   * 
     337   * @see    getComponent 
    305338   */ 
    306339  public function renderComponent($moduleName, $componentName, $vars = null) 
    307340  { 
    308     sfLoader::loadHelpers('Partial'); 
    309  
    310     $vars = !is_null($vars) ? $vars : $this->varHolder->getAll(); 
    311  
    312     return $this->renderText(get_component($moduleName, $componentName, $vars)); 
     341    return $this->renderText($this->getComponent($moduleName, $componentName, $vars)); 
    313342  } 
    314343 

The Sensio Labs Network

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