Development

Changeset 5016

You must first sign up to be able to contribute.

Changeset 5016

Show
Ignore:
Timestamp:
09/09/07 17:11:05 (1 year ago)
Author:
fabien
Message:

added a new sfNamespacedParameterHolder, the old sfParameterHolder does not support namespace anymore, changed all parameter and attribute older to use the simple sfParameterHolder except for user attributes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/addon/sfPager.class.php

    r4659 r5016  
    281281  } 
    282282 
    283   public function getParameter($name, $default = null, $ns = null
    284   { 
    285     return $this->parameterHolder->get($name, $default, $ns); 
    286   } 
    287  
    288   public function hasParameter($name, $ns = null
    289   { 
    290     return $this->parameterHolder->has($name, $ns); 
    291   } 
    292  
    293   public function setParameter($name, $value, $ns = null
    294   { 
    295     return $this->parameterHolder->set($name, $value, $ns); 
     283  public function getParameter($name, $default = null
     284  { 
     285    return $this->parameterHolder->get($name, $default); 
     286  } 
     287 
     288  public function hasParameter($name
     289  { 
     290    return $this->parameterHolder->has($name); 
     291  } 
     292 
     293  public function setParameter($name, $value
     294  { 
     295    return $this->parameterHolder->set($name, $value); 
    296296  } 
    297297} 
  • trunk/lib/cache/sfCache.class.php

    r4957 r5016  
    200200  } 
    201201 
    202   public function getParameter($name, $default = null, $ns = null
    203   { 
    204     return $this->parameterHolder->get($name, $default, $ns); 
    205   } 
    206  
    207   public function hasParameter($name, $ns = null
    208   { 
    209     return $this->parameterHolder->has($name, $ns); 
    210   } 
    211  
    212   public function setParameter($name, $value, $ns = null
    213   { 
    214     return $this->parameterHolder->set($name, $value, $ns); 
     202  public function getParameter($name, $default = null
     203  { 
     204    return $this->parameterHolder->get($name, $default); 
     205  } 
     206 
     207  public function hasParameter($name
     208  { 
     209    return $this->parameterHolder->has($name); 
     210  } 
     211 
     212  public function setParameter($name, $value
     213  { 
     214    return $this->parameterHolder->set($name, $value); 
    215215  } 
    216216 
  • trunk/lib/database/sfDatabase.class.php

    r4957 r5016  
    115115   * @param string The key name 
    116116   * @param string The default value 
    117    * @param string The namespace to use 
    118117   * 
    119118   * @return string The value associated with the key 
     
    121120   * @see sfParameterHolder 
    122121   */ 
    123   public function getParameter($name, $default = null, $ns = null
     122  public function getParameter($name, $default = null
    124123  { 
    125     return $this->parameterHolder->get($name, $default, $ns); 
     124    return $this->parameterHolder->get($name, $default); 
    126125  } 
    127126 
     
    134133   * 
    135134   * @param string The key name 
    136    * @param string The namespace to use 
    137135   * 
    138136   * @return boolean true if the given key exists, false otherwise 
     
    140138   * @see sfParameterHolder 
    141139   */ 
    142   public function hasParameter($name, $ns = null
     140  public function hasParameter($name
    143141  { 
    144     return $this->parameterHolder->has($name, $ns); 
     142    return $this->parameterHolder->has($name); 
    145143  } 
    146144 
     
    154152   * @param string The key name 
    155153   * @param string The value 
    156    * @param string The namespace to use 
    157154   * 
    158155   * @see sfParameterHolder 
    159156   */ 
    160   public function setParameter($name, $value, $ns = null
     157  public function setParameter($name, $value
    161158  { 
    162     $this->parameterHolder->set($name, $value, $ns); 
     159    $this->parameterHolder->set($name, $value); 
    163160  } 
    164161 
  • trunk/lib/debug/sfDebug.class.php

    r3786 r5016  
    152152  { 
    153153    $values = array(); 
    154     foreach ($parameterHolder->getNamespaces() as $ns
     154    if ($parameterHolder instanceof sfNamespacedParameterHolder
    155155    { 
    156       $values[$ns] = array(); 
    157       foreach ($parameterHolder->getAll($ns) as $key => $value) 
     156      foreach ($parameterHolder->getNamespaces() as $ns) 
    158157      { 
    159         $values[$ns][$key] = $value; 
     158        $values[$ns] = array(); 
     159        foreach ($parameterHolder->getAll($ns) as $key => $value) 
     160        { 
     161          $values[$ns][$key] = $value; 
     162        } 
     163        ksort($values[$ns]); 
    160164      } 
    161       ksort($values[$ns]); 
     165    } 
     166    else 
     167    { 
     168      foreach ($parameterHolder->getAll() as $key => $value) 
     169      { 
     170        $values[$key] = $value; 
     171      } 
    162172    } 
    163173 
  • trunk/lib/event/sfEvent.class.php

    r5015 r5016  
    107107  } 
    108108 
    109   public function getParameter($name, $default = null, $ns = null
     109  public function getParameter($name, $default = null
    110110  { 
    111     return $this->parameterHolder->get($name, $default, $ns); 
     111    return $this->parameterHolder->get($name, $default); 
    112112  } 
    113113 
    114   public function hasParameter($name, $ns = null
     114  public function hasParameter($name
    115115  { 
    116     return $this->parameterHolder->has($name, $ns); 
     116    return $this->parameterHolder->has($name); 
    117117  } 
    118118 
    119   public function setParameter($name, $value, $ns = null
     119  public function setParameter($name, $value
    120120  { 
    121     return $this->parameterHolder->set($name, $value, $ns); 
     121    return $this->parameterHolder->set($name, $value); 
    122122  } 
    123123} 
  • trunk/lib/filter/sfFilter.class.php

    r4957 r5016  
    107107   * @param string The key name 
    108108   * @param string The default value 
    109    * @param string The namespace to use 
    110109   * 
    111110   * @return string The value associated with the key 
     
    113112   * @see sfParameterHolder 
    114113   */ 
    115   public function getParameter($name, $default = null, $ns = null
     114  public function getParameter($name, $default = null
    116115  { 
    117     return $this->parameterHolder->get($name, $default, $ns); 
     116    return $this->parameterHolder->get($name, $default); 
    118117  } 
    119118 
     
    126125   * 
    127126   * @param string The key name 
    128    * @param string The namespace to use 
    129127   * 
    130128   * @return boolean true if the given key exists, false otherwise 
     
    132130   * @see sfParameterHolder 
    133131   */ 
    134   public function hasParameter($name, $ns = null
     132  public function hasParameter($name
    135133  { 
    136     return $this->parameterHolder->has($name, $ns); 
     134    return $this->parameterHolder->has($name); 
    137135  } 
    138136 
     
    146144   * @param string The key name 
    147145   * @param string The value 
    148    * @param string The namespace to use 
    149146   * 
    150147   * @see sfParameterHolder 
    151148   */ 
    152   public function setParameter($name, $value, $ns = null
     149  public function setParameter($name, $value
    153150  { 
    154     return $this->parameterHolder->set($name, $value, $ns); 
     151    return $this->parameterHolder->set($name, $value); 
    155152  } 
    156153} 
  • trunk/lib/request/sfRequest.class.php

    r4957 r5016  
    297297   * @param string Attribute name 
    298298   * @param string Default attribute value 
    299    * @param string Namespace for the current request 
    300299   * 
    301300   * @return mixed An attribute value 
    302301   */ 
    303   public function getAttribute($name, $default = null, $ns = null
    304   { 
    305     return $this->attributeHolder->get($name, $default, $ns); 
     302  public function getAttribute($name, $default = null
     303  { 
     304    return $this->attributeHolder->get($name, $default); 
    306305  } 
    307306 
     
    310309   * 
    311310   * @param string Attribute name 
    312    * @param string Namespace for the current request 
    313311   * 
    314312   * @return boolean true, if the attribute exists otherwise false 
    315313   */ 
    316   public function hasAttribute($name, $ns = null
    317   { 
    318     return $this->attributeHolder->has($name, $ns); 
     314  public function hasAttribute($name
     315  { 
     316    return $this->attributeHolder->has($name); 
    319317  } 
    320318 
     
    324322   * @param string Attribute name 
    325323   * @param string Value for the attribute 
    326    * @param string Namespace for the current request 
    327    * 
    328    */ 
    329   public function setAttribute($name, $value, $ns = null) 
    330   { 
    331     $this->attributeHolder->set($name, $value, $ns); 
     324   * 
     325   */ 
     326  public function setAttribute($name, $value) 
     327  { 
     328    $this->attributeHolder->set($name, $value); 
    332329  } 
    333330 
     
    337334   * @param string Parameter name 
    338335   * @param string Parameter default value 
    339    * @param string Namespace for the current request 
    340    * 
    341    */ 
    342   public function getParameter($name, $default = null, $ns = null) 
    343   { 
    344     return $this->parameterHolder->get($name, $default, $ns); 
     336   * 
     337   */ 
     338  public function getParameter($name, $default = null) 
     339  { 
     340    return $this->parameterHolder->get($name, $default); 
    345341  } 
    346342 
     
    349345   * 
    350346   * @param string Parameter name 
    351    * @param string Namespace for the current request 
    352347   * 
    353348   * @return boolean true, if the paramater exists otherwise false 
    354349   */ 
    355   public function hasParameter($name, $ns = null
    356   { 
    357     return $this->parameterHolder->has($name, $ns); 
     350  public function hasParameter($name
     351  { 
     352    return $this->parameterHolder->has($name); 
    358353  } 
    359354 
     
    363358   * @param string Parameter name 
    364359   * @param string Parameter value 
    365    * @param string Namespace for the current request 
    366    * 
    367    */ 
    368   public function setParameter($name, $value, $ns = null) 
    369   { 
    370     $this->parameterHolder->set($name, $value, $ns); 
     360   * 
     361   */ 
     362  public function setParameter($name, $value) 
     363  { 
     364    $this->parameterHolder->set($name, $value); 
    371365  } 
    372366 
  • trunk/lib/request/sfWebRequest.class.php

    r4951 r5016  
    823823    $this->parameterHolder->add($this->postParameters); 
    824824 
    825     // move symfony parameters in a protected namespace (parameters prefixed with _sf_) 
     825    // move symfony parameters to attributes (parameters prefixed with _sf_) 
    826826    foreach ($this->parameterHolder->getAll() as $key => $value) 
    827827    { 
     
    829829      { 
    830830        $this->parameterHolder->remove($key); 
    831         $this->setParameter($key, $value, 'symfony/request/sfWebRequest'); 
     831        $this->setAttribute($key, $value); 
    832832      } 
    833833    } 
  • trunk/lib/response/sfResponse.class.php

    r4957 r5016  
    3939   * 
    4040   * @param  sfEventDispatcher  A sfEventDispatcher instance 
    41    * @param  array         An array of parameters 
     41   * @param  array              An array of parameters 
    4242   * 
    43    * @return Boolean       true, if initialization completes successfully, otherwise false 
     43   * @return Boolean            true, if initialization completes successfully, otherwise false 
    4444   * 
    4545   * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfResponse 
     
    101101   * @param string A parameter name 
    102102   * @param string A default paramter value 
    103    * @param string Namespace for the current response 
    104103   * 
    105104   * @return mixed A parameter value 
    106105   */ 
    107   public function getParameter($name, $default = null, $ns = null
     106  public function getParameter($name, $default = null
    108107  { 
    109     return $this->parameterHolder->get($name, $default, $ns); 
     108    return $this->parameterHolder->get($name, $default); 
    110109  } 
    111110 
     
    114113   * 
    115114   * @param string A parameter name 
    116    * @param string Namespace for the current response 
    117115   * 
    118116   * @return boolean true, if the parameter exists otherwise false 
    119117   */ 
    120   public function hasParameter($name, $ns = null
     118  public function hasParameter($name
    121119  { 
    122     return $this->parameterHolder->has($name, $ns); 
     120    return $this->parameterHolder->has($name); 
    123121  } 
    124122 
     
    128126   * @param string A parameter name 
    129127   * @param string The parameter value to be set 
    130    * @param string Namespace for the current response 
    131128   */ 
    132   public function setParameter($name, $value, $ns = null
     129  public function setParameter($name, $value
    133130  { 
    134     $this->parameterHolder->set($name, $value, $ns); 
     131    $this->parameterHolder->set($name, $value); 
    135132  } 
    136133 
  • trunk/lib/response/sfWebResponse.class.php

    r4951 r5016  
    2626    $statusText  = 'OK', 
    2727    $statusTexts = array(), 
    28     $headerOnly  = false; 
     28    $headerOnly  = false, 
     29    $headers     = array(), 
     30    $metas       = array(), 
     31    $httpMetas   = array(), 
     32    $stylesheets = array(), 
     33    $javascripts = array(); 
    2934 
    3035  /** 
     
    3237   * 
    3338   * @param  sfEventDispatcher  A sfEventDispatcher instance 
    34    * @param  array         An array of parameters 
    35    * 
    36    * @return Boolean       true, if initialization completes successfully, otherwise false 
     39   * @param  array              An array of parameters 
     40   * 
     41   * @return Boolean            true, if initialization completes successfully, otherwise false 
    3742   * 
    3843   * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfResponse 
     
    188193    if (is_null($value)) 
    189194    { 
    190       $this->getParameterHolder()->remove($name, 'symfony/response/http/headers'); 
     195      unset($this->headers[$name]); 
    191196 
    192197      return; 
     
    205210    if (!$replace) 
    206211    { 
    207       $current = $this->getParameter($name, '', 'symfony/response/http/headers')
     212      $current = isset($this->headers[$name]) ? $this->headers[$name] : ''
    208213      $value = ($current ? $current.', ' : '').$value; 
    209214    } 
    210215 
    211     $this->setParameter($name, $value, 'symfony/response/http/headers')
     216    $this->headers[$name] = $value
    212217  } 
    213218 
     
    219224  public function getHttpHeader($name, $default = null) 
    220225  { 
    221     return $this->getParameter($this->normalizeHeaderName($name), $default, 'symfony/response/http/headers'); 
     226    $name = $this->normalizeHeaderName($name); 
     227 
     228    return isset($this->headers[$name]) ? $this->headers[$name] : $default; 
    222229  } 
    223230 
     
    229236  public function hasHttpHeader($name) 
    230237  { 
    231     return $this->hasParameter($this->normalizeHeaderName($name), 'symfony/response/http/headers'); 
     238    return array_key_exists($this->normalizeHeaderName($name), $this->headers); 
    232239  } 
    233240 
     
    246253    } 
    247254 
    248     $this->setParameter('Content-Type', $value, 'symfony/response/http/headers')
     255    $this->headers['Content-Type'] = $value
    249256  } 
    250257 
     
    275282 
    276283    // headers 
    277     foreach ($this->getParameterHolder()->getAll('symfony/response/http/headers') as $name => $value) 
     284    foreach ($this->headers as $name => $value) 
    278285    { 
    279286      header($name.': '.$value); 
     
    425432  public function getHttpMetas() 
    426433  { 
    427     return $this->getParameterHolder()->getAll('helper/asset/auto/httpmeta')
     434    return $this->httpMetas
    428435  } 
    429436 
     
    444451    if (is_null($value)) 
    445452    { 
    446       $this->getParameterHolder()->remove($key, 'helper/asset/auto/httpmeta'); 
     453      unset($this->httpMetas[$key]); 
    447454 
    448455      return; 
     
    456463    if (!$replace) 
    457464    { 
    458       $current = $this->getParameter($key, '', 'helper/asset/auto/httpmeta')
     465      $current = isset($this->httpMetas[$key]) ? $this->httpMetas[$key] : ''
    459466      $value = ($current ? $current.', ' : '').$value; 
    460467    } 
    461468 
    462     $this->setParameter($key, $value, 'helper/asset/auto/httpmeta')
     469    $this->httpMetas[$key] = $value
    463470  } 
    464471 
     
    470477  public function getMetas() 
    471478  { 
    472     return $this->getParameterHolder()->getAll('helper/asset/auto/meta')
     479    return $this->metas
    473480  } 
    474481 
     
    487494    if (is_null($value)) 
    488495    { 
    489       $this->getParameterHolder()->remove($key, 'helper/asset/auto/meta'); 
     496      unset($this->metas[$key]); 
    490497 
    491498      return; 
     
    499506    } 
    500507 
    501     if ($replace || !$this->getParameter($key, null, 'helper/asset/auto/meta')) 
    502     { 
    503       $this->setParameter($key, $value, 'helper/asset/auto/meta'); 
     508    $current = isset($this->metas[$key]) ? $this->metas[$key] : null; 
     509    if ($replace || !$current) 
     510    { 
     511      $this->metas[$key] = $value; 
    504512    } 
    505513  } 
     
    512520  public function getTitle() 
    513521  { 
    514     return $this->getParameter('title', '', 'helper/asset/auto/meta')
     522    return isset($this->metas['title']) ? $this->metas['title'] : ''
    515523  } 
    516524 
     
    529537   * Retrieves stylesheets for the current web response. 
    530538   * 
    531    * @param string Direcotry delimiter 
     539   * @param string Position 
    532540   * 
    533541   * @return string Stylesheets 
     
    535543  public function getStylesheets($position = '') 
    536544  { 
    537     return $this->getParameterHolder()->getAll('helper/asset/auto/stylesheet'.($position ? '/'.$position : '')); 
     545    if ($position == 'ALL') 
     546    { 
     547      return $this->stylesheets; 
     548    } 
     549 
     550    return isset($this->stylesheets[$position]) ? $this->stylesheets[$position] : array(); 
    538551  } 
    539552 
     
    542555   * 
    543556   * @param string Stylesheet 
    544    * @param string Direcotry delimiter 
     557   * @param string Position 
    545558   * @param string Stylesheet options 
    546559   */ 
    547560  public function addStylesheet($css, $position = '', $options = array()) 
    548561  { 
    549     $this->setParameter($css, $options, 'helper/asset/auto/stylesheet'.($position ? '/'.$position : '')); 
     562    if (!isset($this->stylesheets[$position])) 
     563    { 
     564      $this->stylesheets[$position] = array(); 
     565    } 
     566 
     567    $this->stylesheets[$position][$css] = $options; 
    550568  } 
    551569 
     
    559577  public function getJavascripts($position = '') 
    560578  { 
    561     return $this->getParameterHolder()->getAll('helper/asset/auto/javascript'.($position ? '/'.$position : '')); 
     579    if ($position == 'ALL') 
     580    { 
     581      return $this->javascripts; 
     582    } 
     583 
     584    return isset($this->javascript[$position]) ? $this->javascript[$position] : array(); 
    562585  } 
    563586 
     
    571594  public function addJavascript($js, $position = '', $options = array()) 
    572595  { 
    573     $this->setParameter($js, $options, 'helper/asset/auto/javascript'.($position ? '/'.$position : '')); 
     596    if (!isset($this->javascript[$position])) 
     597    { 
     598      $this->javascript[$position] = array(); 
     599    } 
     600 
     601    $this->javascript[$position][$js] = $options; 
    574602  } 
    575603 
     
    597625  public function getHttpHeaders() 
    598626  { 
    599     return $this->getParameterHolder()->getAll('symfony/response/http/headers')
     627    return $this->headers
    600628  } 
    601629 
     
    605633  public function clearHttpHeaders() 
    606634  { 
    607     $this->getParameterHolder()->removeNamespace('symfony/response/http/headers'); 
    608   } 
    609  
    610   /** 
    611    * Copies a propertie to a new one. 
    612    * 
    613    * @param sfResponse Response instance 
    614    */ 
    615   public function mergeProperties($response) 
     635    $this->headers = array(); 
     636  } 
     637 
     638  /** 
     639   * Copies all properties from a given sfWebResponse object to the current one. 
     640   * 
     641   * @param sfWebResponse A sfWebResponse instance 
     642   */ 
     643  public function mergeProperties(sfWebResponse $response) 
    616644  { 
    617645    $this->parameterHolder = clone $response->getParameterHolder(); 
     646    $this->headers         = $response->getHttpHeaders(); 
     647    $this->metas           = $response->getMetas(); 
     648    $this->httpMetas       = $response->getHttpMetas(); 
     649    $this->stylesheets     = $response->getStylesheets('ALL'); 
     650    $this->javascripts     = $response->getJavascripts('ALL'); 
    618651  } 
    619652 
     
    625658  public function serialize() 
    626659  { 
    627     return serialize(array($this->content, $this->statusCode, $this->statusText, $this->parameterHolder, $this->cookies, $this->headerOnly)); 
     660    return serialize(array($this->content, $this->statusCode, $this->statusText, $this->parameterHolder, $this->cookies, $this->headerOnly, $this->headers, $this->metas, $this->httpMetas, $this->stylesheets, $this->javascripts)); 
    628661  } 
    629662 
     
    637670    $this->initialize(sfContext::hasInstance() ? sfContext::getInstance()->getEventDispatcher() : new sfEventDispatcher()); 
    638671 
    639     $this->content         = $data[0]; 
    640     $this->statusCode      = $data[1]; 
    641     $this->statusText      = $data[2]; 
    642     $this->parameterHolder = $data[3]; 
    643     $this->cookies         = $data[4]; 
    644     $this->headerOnly      = $data[5]; 
     672    list($this->content, $this->statusCode, $this->statusText, $this->parameterHolder, $this->cookies, $this->headerOnly, $this->headers, $this->metas, $this->httpMetas, $this->stylesheets, $this->javascripts) = $data; 
    645673  } 
    646674 
  • trunk/lib/storage/sfStorage.class.php

    r4961 r5016  
    5151  { 
    5252    $this->parameterHolder = new sfParameterHolder(); 
    53     $this->getParameterHolder()->add($parameters); 
     53    $this->parameterHolder->add($parameters); 
    5454  } 
    5555 
     
    114114   * @param string Parameter name 
    115115   * @param mixed A default parameter 
    116    * @param string Namespace for the current storage 
    117116   * 
    118117   * @return mixed A parameter value 
    119118   */ 
    120   public function getParameter($name, $default = null, $ns = null
     119  public function getParameter($name, $default = null
    121120  { 
    122     return $this->parameterHolder->get($name, $default, $ns); 
     121    return $this->parameterHolder->get($name, $default); 
    123122  } 
    124123 
     
    127126   * 
    128127   * @param string A parameter name 
    129    * @param string A parameter namespace 
    130128   * 
    131129   * @return boolean true, if parameter exists, otherwise false 
    132130   */ 
    133   public function hasParameter($name, $ns = null
     131  public function hasParameter($name
    134132  { 
    135     return $this->parameterHolder->has($name, $ns); 
     133    return $this->parameterHolder->has($name); 
    136134  } 
    137135 
     
    141139   * @param string A parameter name 
    142140   * @param mixed A parameter value 
    143    * @param string Namespace for the current storage 
    144141   */ 
    145   public function setParameter($name, $value, $ns = null
     142  public function setParameter($name, $value
    146143  { 
    147     return $this->parameterHolder->set($name, $value, $ns); 
     144    return $this->parameterHolder->set($name, $value); 
    148145  } 
    149146} 
  • trunk/lib/user/sfUser.class.php

    r4961 r5016  
    7373    $this->parameterHolder->add($parameters); 
    7474 
    75     $this->attributeHolder = new sfParameterHolder(self::ATTRIBUTE_NAMESPACE); 
     75    $this->attributeHolder = new sfNamespacedParameterHolder(self::ATTRIBUTE_NAMESPACE); 
    7676 
    7777    // read attributes from storage 
     
    218218  } 
    219219 
    220   public function getParameter($name, $default = null, $ns = null
    221   { 
    222     return $this->parameterHolder->get($name, $default, $ns); 
    223   } 
    224  
    225   public function hasParameter($name, $ns = null
    226   { 
    227     return $this->parameterHolder->has($name, $ns); 
    228   } 
    229  
    230   public function setParameter($name, $value, $ns = null
    231   { 
    232     return $this->parameterHolder->set($name, $value, $ns); 
     220  public function getParameter($name, $default = null
     221  { 
     222    return $this->parameterHolder->get($name, $default); 
     223  } 
     224 
     225  public function hasParameter($name
     226  { 
     227    return $this->parameterHolder->has($name); 
     228  } 
     229 
     230  public function setParameter($name, $value
     231  { 
     232    return $this->parameterHolder->set($name, $value); 
    233233  } 
    234234 
  • trunk/lib/util/sfParameterHolder.class.php

    r4898 r5016  
    2424class sfParameterHolder implements Serializable 
    2525{ 
    26   protected $default_namespace = null; 
    2726  protected $parameters = array(); 
    2827 
    2928  /** 
    3029   * The constructor for sfParameterHolder. 
    31    *  
    32    * The default namespace may be overridden at initialization as follows: 
    33    * <code> 
    34    * <?php 
    35    * $mySpecialPH = new sfParameterHolder('symfony/special'); 
    36    * ?> 
    37    * </code> 
    38    */ 
    39   public function __construct($namespace = 'symfony/default') 
    40   { 
    41     $this->default_namespace = $namespace; 
    42   } 
    43  
    44   /** 
    45    * Sets the default namespace value. 
    46    * 
    47    * @param string  Default namespace. 
    48    * @param Boolean Move all values of the old default namespace to the new one or not. 
    49    */ 
    50   public function setDefaultNamespace($namespace, $move = true) 
    51   { 
    52     if ($move) 
    53     { 
    54       $values = $this->removeNamespace(); 
    55       $this->addByRef($values, $namespace); 
    56     } 
    57  
    58     $this->default_namespace = $namespace; 
    59   } 
    60  
    61   /** 
    62    * Get the default namespace value. 
    63    * 
    64    * The $default_namespace is defined as 'symfony/default'. 
    65    * 
    66    * @return string The default namespace. 
    67    */ 
    68   public function getDefaultNamespace() 
    69   { 
    70     return $this->default_namespace; 
    71   } 
    72  
    73   /** 
    74    * Clear all parameters associated with this request. 
    75    * 
    76    * @return void 
     30   */ 
     31  public function __construct() 
     32  { 
     33  } 
     34 
     35  /** 
     36   * Clears all parameters associated with this request. 
    7737   */ 
    7838  public function clear() 
    7939  { 
    80     $this->parameters = null; 
    8140    $this->parameters = array(); 
    8241  } 
    8342 
    8443  /** 
    85    * Retrieve a parameter with an optionally specified namespace. 
    86    * 
    87    * An isolated namespace may be identified by providing a value for the third 
    88    * argument.  If not specified, the default namespace 'symfony/default' is 
    89    * used. 
     44   * Retrieves a parameter. 
    9045   * 
    9146   * @param string A parameter name. 
    9247   * @param mixed  A default parameter value. 
    93    * @param string A parameter namespace. 
    9448   * 
    9549   * @return mixed A parameter value, if the parameter exists, otherwise null. 
    9650   */ 
    97   public function & get($name, $default = null, $ns = null) 
    98   { 
    99     if (!$ns) 
    100     { 
    101       $ns = $this->default_namespace; 
    102     } 
    103  
    104     if (isset($this->parameters[$ns][$name])) 
    105     { 
    106       $value = & $this->parameters[$ns][$name]; 
    107     } 
    108     else if (isset($this->parameters[$ns])) 
    109     { 
    110       $value = sfToolkit::getArrayValueForPath($this->parameters[$ns], $name, $default); 
     51  public function & get($name, $default = null) 
     52  { 
     53    if (isset($this->parameters[$name])) 
     54    { 
     55      $value = & $this->parameters[$name]; 
    11156    } 
    11257    else 
    11358    { 
    114       $value = $default
     59      $value = sfToolkit::getArrayValueForPath($this->parameters, $name, $default)
    11560    } 
    11661 
     
    11964 
    12065  /** 
    121    * Retrieve an array of parameter names from an optionally specified namespace. 
    122    * 
    123    * @param string A parameter namespace. 
    124    * 
    125    * @return array An indexed array of parameter names, if the namespace exists, otherwise null. 
    126    */ 
    127   public function getNames($ns = null) 
    128   { 
    129     if (!$ns) 
    130     { 
    131       $ns = $this->default_namespace; 
    132     } 
    133  
    134     if (isset($this->parameters[$ns])) 
    135     { 
    136       return array_keys($this->parameters[$ns]); 
    137     } 
    138  
    139     return array(); 
    140   } 
    141  
    142   /** 
    143    * Retrieve an array of parameter namespaces. 
    144    * 
    145    * @return array An indexed array of parameter namespaces. 
    146    */ 
    147   public function getNamespaces() 
     66   * Retrieves an array of parameter names. 
     67   * 
     68   * @return array An indexed array of parameter names. 
     69   */ 
     70  public function getNames() 
    14871  { 
    14972    return array_keys($this->parameters); 
     
    15174 
    15275  /** 
    153    * Retrieve an array of parameters, within a namespace. 
    154    * 
    155    * This method is limited to a namespace.  Without any argument, 
    156    * it returns the parameters of the default namespace.  If a  
    157    * namespace is passed as an argument, only the parameters of the 
    158    * specified namespace are returned. 
    159    * 
    160    * @param string A parameter namespace. 
     76   * Retrieves an array of parameters. 
    16177   * 
    16278   * @return array An associative array of parameters. 
    16379   */ 
    164   public function & getAll($ns = null) 
    165   { 
    166     if (!$ns) 
    167     { 
    168       $ns = $this->default_namespace; 
    169     } 
    170  
    171     $parameters = array(); 
    172  
    173     if (isset($this->parameters[$ns])) 
    174     { 
    175       $parameters = $this->parameters[$ns]; 
    176     } 
    177  
    178     return $parameters; 
     80  public function & getAll() 
     81  { 
     82    return $this->parameters; 
    17983  } 
    18084 
     
    18387   * 
    18488   * @param string A parameter name. 
    185    * @param string A parameter namespace. 
    18689   * 
    18790   * @return bool true, if the parameter exists, otherwise false. 
    18891   */ 
    189   public function has($name, $ns = null) 
    190   { 
    191     if (!$ns) 
    192     { 
    193       $ns = $this->default_namespace; 
    194     } 
    195  
     92  public function has($name) 
     93  { 
    19694    if (false !== ($offset = strpos($name, '['))) 
    19795    { 
    198       if (isset($this->parameters[$ns][substr($name, 0, $offset)])) 
     96      if (isset($this->parameters[substr($name, 0, $offset)])) 
    19997      { 
    200         $array = $this->parameters[$ns][substr($name, 0, $offset)]; 
     98        $array = $this->parameters[substr($name, 0, $offset)]; 
    20199 
    202100        while ($pos = strpos($name, '[', $offset)) 
     
    219117      } 
    220118    } 
    221     elseif (isset($this->parameters[$ns][$name])) 
     119    elseif (isset($this->parameters[$name])) 
    222120    { 
    223121      return true; 
     
    228126 
    229127  /** 
    230    * Indicates whether or not A parameter namespace exists. 
    231    * 
    232    * @param string A parameter namespace. 
    233    * 
    234    * @return bool true, if the namespace exists, otherwise false. 
    235    */ 
    236   public function hasNamespace($ns) 
    237   { 
    238     return isset($this->parameters[$ns]); 
    239   } 
    240  
    241   /** 
    242128   * Remove a parameter. 
    243129   * 
    244130   * @param string A parameter name. 
    245    * @param string A parameter namespace. 
    246131   * 
    247132   * @return string A parameter value, if the parameter was removed, otherwise null. 
    248133   */ 
    249   public function remove($name, $ns = null) 
    250   { 
    251     if (!$ns)