Changeset 5016
- Timestamp:
- 09/09/07 17:11:05 (1 year ago)
- Files:
-
- trunk/lib/addon/sfPager.class.php (modified) (1 diff)
- trunk/lib/cache/sfCache.class.php (modified) (1 diff)
- trunk/lib/database/sfDatabase.class.php (modified) (5 diffs)
- trunk/lib/debug/sfDebug.class.php (modified) (1 diff)
- trunk/lib/event/sfEvent.class.php (modified) (1 diff)
- trunk/lib/filter/sfFilter.class.php (modified) (5 diffs)
- trunk/lib/request/sfRequest.class.php (modified) (6 diffs)
- trunk/lib/request/sfWebRequest.class.php (modified) (2 diffs)
- trunk/lib/response/sfResponse.class.php (modified) (4 diffs)
- trunk/lib/response/sfWebResponse.class.php (modified) (24 diffs)
- trunk/lib/storage/sfStorage.class.php (modified) (4 diffs)
- trunk/lib/user/sfUser.class.php (modified) (2 diffs)
- trunk/lib/util/sfNamespacedParameterHolder.class.php (added)
- trunk/lib/util/sfParameterHolder.class.php (modified) (13 diffs)
- trunk/lib/validator/sfValidator.class.php (modified) (3 diffs)
- trunk/lib/view/sfView.class.php (modified) (6 diffs)
- trunk/lib/view/sfViewCacheManager.class.php (modified) (1 diff)
- trunk/lib/view/sfViewParameterHolder.class.php (modified) (1 diff)
- trunk/test/bootstrap/unit.php (modified) (1 diff)
- trunk/test/unit/database/sfDatabaseTest.php (modified) (1 diff)
- trunk/test/unit/filter/sfFilterTest.php (modified) (3 diffs)
- trunk/test/unit/request/sfRequestTest.php (modified) (1 diff)
- trunk/test/unit/response/sfResponseTest.php (modified) (1 diff)
- trunk/test/unit/response/sfWebResponseTest.php (modified) (3 diffs)
- trunk/test/unit/sfParameterHolderTest.class.php (modified) (2 diffs)
- trunk/test/unit/storage/sfStorageTest.php (modified) (1 diff)
- trunk/test/unit/user/sfUserTest.php (modified) (1 diff)
- trunk/test/unit/util/sfNamespacedParameterHolderTest.php (moved) (moved from trunk/test/unit/util/sfParameterHolderTest.php) (16 diffs)
- trunk/test/unit/validator/sfValidatorTest.php (modified) (1 diff)
- trunk/test/unit/view/sfViewTest.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/addon/sfPager.class.php
r4659 r5016 281 281 } 282 282 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); 296 296 } 297 297 } trunk/lib/cache/sfCache.class.php
r4957 r5016 200 200 } 201 201 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); 215 215 } 216 216 trunk/lib/database/sfDatabase.class.php
r4957 r5016 115 115 * @param string The key name 116 116 * @param string The default value 117 * @param string The namespace to use118 117 * 119 118 * @return string The value associated with the key … … 121 120 * @see sfParameterHolder 122 121 */ 123 public function getParameter($name, $default = null , $ns = null)122 public function getParameter($name, $default = null) 124 123 { 125 return $this->parameterHolder->get($name, $default , $ns);124 return $this->parameterHolder->get($name, $default); 126 125 } 127 126 … … 134 133 * 135 134 * @param string The key name 136 * @param string The namespace to use137 135 * 138 136 * @return boolean true if the given key exists, false otherwise … … 140 138 * @see sfParameterHolder 141 139 */ 142 public function hasParameter($name , $ns = null)140 public function hasParameter($name) 143 141 { 144 return $this->parameterHolder->has($name , $ns);142 return $this->parameterHolder->has($name); 145 143 } 146 144 … … 154 152 * @param string The key name 155 153 * @param string The value 156 * @param string The namespace to use157 154 * 158 155 * @see sfParameterHolder 159 156 */ 160 public function setParameter($name, $value , $ns = null)157 public function setParameter($name, $value) 161 158 { 162 $this->parameterHolder->set($name, $value , $ns);159 $this->parameterHolder->set($name, $value); 163 160 } 164 161 trunk/lib/debug/sfDebug.class.php
r3786 r5016 152 152 { 153 153 $values = array(); 154 foreach ($parameterHolder->getNamespaces() as $ns)154 if ($parameterHolder instanceof sfNamespacedParameterHolder) 155 155 { 156 $values[$ns] = array(); 157 foreach ($parameterHolder->getAll($ns) as $key => $value) 156 foreach ($parameterHolder->getNamespaces() as $ns) 158 157 { 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]); 160 164 } 161 ksort($values[$ns]); 165 } 166 else 167 { 168 foreach ($parameterHolder->getAll() as $key => $value) 169 { 170 $values[$key] = $value; 171 } 162 172 } 163 173 trunk/lib/event/sfEvent.class.php
r5015 r5016 107 107 } 108 108 109 public function getParameter($name, $default = null , $ns = null)109 public function getParameter($name, $default = null) 110 110 { 111 return $this->parameterHolder->get($name, $default , $ns);111 return $this->parameterHolder->get($name, $default); 112 112 } 113 113 114 public function hasParameter($name , $ns = null)114 public function hasParameter($name) 115 115 { 116 return $this->parameterHolder->has($name , $ns);116 return $this->parameterHolder->has($name); 117 117 } 118 118 119 public function setParameter($name, $value , $ns = null)119 public function setParameter($name, $value) 120 120 { 121 return $this->parameterHolder->set($name, $value , $ns);121 return $this->parameterHolder->set($name, $value); 122 122 } 123 123 } trunk/lib/filter/sfFilter.class.php
r4957 r5016 107 107 * @param string The key name 108 108 * @param string The default value 109 * @param string The namespace to use110 109 * 111 110 * @return string The value associated with the key … … 113 112 * @see sfParameterHolder 114 113 */ 115 public function getParameter($name, $default = null , $ns = null)114 public function getParameter($name, $default = null) 116 115 { 117 return $this->parameterHolder->get($name, $default , $ns);116 return $this->parameterHolder->get($name, $default); 118 117 } 119 118 … … 126 125 * 127 126 * @param string The key name 128 * @param string The namespace to use129 127 * 130 128 * @return boolean true if the given key exists, false otherwise … … 132 130 * @see sfParameterHolder 133 131 */ 134 public function hasParameter($name , $ns = null)132 public function hasParameter($name) 135 133 { 136 return $this->parameterHolder->has($name , $ns);134 return $this->parameterHolder->has($name); 137 135 } 138 136 … … 146 144 * @param string The key name 147 145 * @param string The value 148 * @param string The namespace to use149 146 * 150 147 * @see sfParameterHolder 151 148 */ 152 public function setParameter($name, $value , $ns = null)149 public function setParameter($name, $value) 153 150 { 154 return $this->parameterHolder->set($name, $value , $ns);151 return $this->parameterHolder->set($name, $value); 155 152 } 156 153 } trunk/lib/request/sfRequest.class.php
r4957 r5016 297 297 * @param string Attribute name 298 298 * @param string Default attribute value 299 * @param string Namespace for the current request300 299 * 301 300 * @return mixed An attribute value 302 301 */ 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); 306 305 } 307 306 … … 310 309 * 311 310 * @param string Attribute name 312 * @param string Namespace for the current request313 311 * 314 312 * @return boolean true, if the attribute exists otherwise false 315 313 */ 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); 319 317 } 320 318 … … 324 322 * @param string Attribute name 325 323 * @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); 332 329 } 333 330 … … 337 334 * @param string Parameter name 338 335 * @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); 345 341 } 346 342 … … 349 345 * 350 346 * @param string Parameter name 351 * @param string Namespace for the current request352 347 * 353 348 * @return boolean true, if the paramater exists otherwise false 354 349 */ 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); 358 353 } 359 354 … … 363 358 * @param string Parameter name 364 359 * @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); 371 365 } 372 366 trunk/lib/request/sfWebRequest.class.php
r4951 r5016 823 823 $this->parameterHolder->add($this->postParameters); 824 824 825 // move symfony parameters in a protected namespace(parameters prefixed with _sf_)825 // move symfony parameters to attributes (parameters prefixed with _sf_) 826 826 foreach ($this->parameterHolder->getAll() as $key => $value) 827 827 { … … 829 829 { 830 830 $this->parameterHolder->remove($key); 831 $this->set Parameter($key, $value, 'symfony/request/sfWebRequest');831 $this->setAttribute($key, $value); 832 832 } 833 833 } trunk/lib/response/sfResponse.class.php
r4957 r5016 39 39 * 40 40 * @param sfEventDispatcher A sfEventDispatcher instance 41 * @param array An array of parameters41 * @param array An array of parameters 42 42 * 43 * @return Boolean true, if initialization completes successfully, otherwise false43 * @return Boolean true, if initialization completes successfully, otherwise false 44 44 * 45 45 * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfResponse … … 101 101 * @param string A parameter name 102 102 * @param string A default paramter value 103 * @param string Namespace for the current response104 103 * 105 104 * @return mixed A parameter value 106 105 */ 107 public function getParameter($name, $default = null , $ns = null)106 public function getParameter($name, $default = null) 108 107 { 109 return $this->parameterHolder->get($name, $default , $ns);108 return $this->parameterHolder->get($name, $default); 110 109 } 111 110 … … 114 113 * 115 114 * @param string A parameter name 116 * @param string Namespace for the current response117 115 * 118 116 * @return boolean true, if the parameter exists otherwise false 119 117 */ 120 public function hasParameter($name , $ns = null)118 public function hasParameter($name) 121 119 { 122 return $this->parameterHolder->has($name , $ns);120 return $this->parameterHolder->has($name); 123 121 } 124 122 … … 128 126 * @param string A parameter name 129 127 * @param string The parameter value to be set 130 * @param string Namespace for the current response131 128 */ 132 public function setParameter($name, $value , $ns = null)129 public function setParameter($name, $value) 133 130 { 134 $this->parameterHolder->set($name, $value , $ns);131 $this->parameterHolder->set($name, $value); 135 132 } 136 133 trunk/lib/response/sfWebResponse.class.php
r4951 r5016 26 26 $statusText = 'OK', 27 27 $statusTexts = array(), 28 $headerOnly = false; 28 $headerOnly = false, 29 $headers = array(), 30 $metas = array(), 31 $httpMetas = array(), 32 $stylesheets = array(), 33 $javascripts = array(); 29 34 30 35 /** … … 32 37 * 33 38 * @param sfEventDispatcher A sfEventDispatcher instance 34 * @param array An array of parameters35 * 36 * @return Boolean true, if initialization completes successfully, otherwise false39 * @param array An array of parameters 40 * 41 * @return Boolean true, if initialization completes successfully, otherwise false 37 42 * 38 43 * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfResponse … … 188 193 if (is_null($value)) 189 194 { 190 $this->getParameterHolder()->remove($name, 'symfony/response/http/headers');195 unset($this->headers[$name]); 191 196 192 197 return; … … 205 210 if (!$replace) 206 211 { 207 $current = $this->getParameter($name, '', 'symfony/response/http/headers');212 $current = isset($this->headers[$name]) ? $this->headers[$name] : ''; 208 213 $value = ($current ? $current.', ' : '').$value; 209 214 } 210 215 211 $this-> setParameter($name, $value, 'symfony/response/http/headers');216 $this->headers[$name] = $value; 212 217 } 213 218 … … 219 224 public function getHttpHeader($name, $default = null) 220 225 { 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; 222 229 } 223 230 … … 229 236 public function hasHttpHeader($name) 230 237 { 231 return $this->hasParameter($this->normalizeHeaderName($name), 'symfony/response/http/headers');238 return array_key_exists($this->normalizeHeaderName($name), $this->headers); 232 239 } 233 240 … … 246 253 } 247 254 248 $this-> setParameter('Content-Type', $value, 'symfony/response/http/headers');255 $this->headers['Content-Type'] = $value; 249 256 } 250 257 … … 275 282 276 283 // headers 277 foreach ($this-> getParameterHolder()->getAll('symfony/response/http/headers')as $name => $value)284 foreach ($this->headers as $name => $value) 278 285 { 279 286 header($name.': '.$value); … … 425 432 public function getHttpMetas() 426 433 { 427 return $this-> getParameterHolder()->getAll('helper/asset/auto/httpmeta');434 return $this->httpMetas; 428 435 } 429 436 … … 444 451 if (is_null($value)) 445 452 { 446 $this->getParameterHolder()->remove($key, 'helper/asset/auto/httpmeta');453 unset($this->httpMetas[$key]); 447 454 448 455 return; … … 456 463 if (!$replace) 457 464 { 458 $current = $this->getParameter($key, '', 'helper/asset/auto/httpmeta');465 $current = isset($this->httpMetas[$key]) ? $this->httpMetas[$key] : ''; 459 466 $value = ($current ? $current.', ' : '').$value; 460 467 } 461 468 462 $this-> setParameter($key, $value, 'helper/asset/auto/httpmeta');469 $this->httpMetas[$key] = $value; 463 470 } 464 471 … … 470 477 public function getMetas() 471 478 { 472 return $this-> getParameterHolder()->getAll('helper/asset/auto/meta');479 return $this->metas; 473 480 } 474 481 … … 487 494 if (is_null($value)) 488 495 { 489 $this->getParameterHolder()->remove($key, 'helper/asset/auto/meta');496 unset($this->metas[$key]); 490 497 491 498 return; … … 499 506 } 500 507 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; 504 512 } 505 513 } … … 512 520 public function getTitle() 513 521 { 514 return $this->getParameter('title', '', 'helper/asset/auto/meta');522 return isset($this->metas['title']) ? $this->metas['title'] : ''; 515 523 } 516 524 … … 529 537 * Retrieves stylesheets for the current web response. 530 538 * 531 * @param string Direcotry delimiter539 * @param string Position 532 540 * 533 541 * @return string Stylesheets … … 535 543 public function getStylesheets($position = '') 536 544 { 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(); 538 551 } 539 552 … … 542 555 * 543 556 * @param string Stylesheet 544 * @param string Direcotry delimiter557 * @param string Position 545 558 * @param string Stylesheet options 546 559 */ 547 560 public function addStylesheet($css, $position = '', $options = array()) 548 561 { 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; 550 568 } 551 569 … … 559 577 public function getJavascripts($position = '') 560 578 { 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(); 562 585 } 563 586 … … 571 594 public function addJavascript($js, $position = '', $options = array()) 572 595 { 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; 574 602 } 575 603 … … 597 625 public function getHttpHeaders() 598 626 { 599 return $this-> getParameterHolder()->getAll('symfony/response/http/headers');627 return $this->headers; 600 628 } 601 629 … … 605 633 public function clearHttpHeaders() 606 634 { 607 $this-> getParameterHolder()->removeNamespace('symfony/response/http/headers');608 } 609 610 /** 611 * Copies a propertie to a newone.612 * 613 * @param sf ResponseResponse instance614 */ 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) 616 644 { 617 645 $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'); 618 651 } 619 652 … … 625 658 public function serialize() 626 659 { 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)); 628 661 } 629 662 … … 637 670 $this->initialize(sfContext::hasInstance() ? sfContext::getInstance()->getEventDispatcher() : new sfEventDispatcher()); 638 671 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; 645 673 } 646 674 trunk/lib/storage/sfStorage.class.php
r4961 r5016 51 51 { 52 52 $this->parameterHolder = new sfParameterHolder(); 53 $this-> getParameterHolder()->add($parameters);53 $this->parameterHolder->add($parameters); 54 54 } 55 55 … … 114 114 * @param string Parameter name 115 115 * @param mixed A default parameter 116 * @param string Namespace for the current storage117 116 * 118 117 * @return mixed A parameter value 119 118 */ 120 public function getParameter($name, $default = null , $ns = null)119 public function getParameter($name, $default = null) 121 120 { 122 return $this->parameterHolder->get($name, $default , $ns);121 return $this->parameterHolder->get($name, $default); 123 122 } 124 123 … … 127 126 * 128 127 * @param string A parameter name 129 * @param string A parameter namespace130 128 * 131 129 * @return boolean true, if parameter exists, otherwise false 132 130 */ 133 public function hasParameter($name , $ns = null)131 public function hasParameter($name) 134 132 { 135 return $this->parameterHolder->has($name , $ns);133 return $this->parameterHolder->has($name); 136 134 } 137 135 … … 141 139 * @param string A parameter name 142 140 * @param mixed A parameter value 143 * @param string Namespace for the current storage144 141 */ 145 public function setParameter($name, $value , $ns = null)142 public function setParameter($name, $value) 146 143 { 147 return $this->parameterHolder->set($name, $value , $ns);144 return $this->parameterHolder->set($name, $value); 148 145 } 149 146 } trunk/lib/user/sfUser.class.php
r4961 r5016 73 73 $this->parameterHolder->add($parameters); 74 74 75 $this->attributeHolder = new sf ParameterHolder(self::ATTRIBUTE_NAMESPACE);75 $this->attributeHolder = new sfNamespacedParameterHolder(self::ATTRIBUTE_NAMESPACE); 76 76 77 77 // read attributes from storage … … 218 218 } 219 219 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); 233 233 } 234 234 trunk/lib/util/sfParameterHolder.class.php
r4898 r5016 24 24 class sfParameterHolder implements Serializable 25 25 { 26 protected $default_namespace = null;27 26 protected $parameters = array(); 28 27 29 28 /** 30 29 * 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. 77 37 */ 78 38 public function clear() 79 39 { 80 $this->parameters = null;81 40 $this->parameters = array(); 82 41 } 83 42 84 43 /** 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. 90 45 * 91 46 * @param string A parameter name. 92 47 * @param mixed A default parameter value. 93 * @param string A parameter namespace.94 48 * 95 49 * @return mixed A parameter value, if the parameter exists, otherwise null. 96 50 */ 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]; 111 56 } 112 57 else 113 58 { 114 $value = $default;59 $value = sfToolkit::getArrayValueForPath($this->parameters, $name, $default); 115 60 } 116 61 … … 119 64 120 65 /** 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() 148 71 { 149 72 return array_keys($this->parameters); … … 151 74 152 75 /** 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. 161 77 * 162 78 * @return array An associative array of parameters. 163 79 */ 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; 179 83 } 180 84 … … 183 87 * 184 88 * @param string A parameter name. 185 * @param string A parameter namespace.186 89 * 187 90 * @return bool true, if the parameter exists, otherwise false. 188 91 */ 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 { 196 94 if (false !== ($offset = strpos($name, '['))) 197 95 { 198 if (isset($this->parameters[ $ns][substr($name, 0, $offset)]))96 if (isset($this->parameters[substr($name, 0, $offset)])) 199 97 { 200 $array = $this->parameters[ $ns][substr($name, 0, $offset)];98 $array = $this->parameters[substr($name, 0, $offset)]; 201 99 202 100 while ($pos = strpos($name, '[', $offset)) … … 219 117 } 220 118 } 221 elseif (isset($this->parameters[$n s][$name]))119 elseif (isset($this->parameters[$name])) 222 120 { 223 121 return true; … … 228 126 229 127 /** 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 /**242 128 * Remove a parameter. 243 129 * 244 130 * @param string A parameter name. 245 * @param string A parameter namespace.246 131 * 247 132 * @return string A parameter value, if the parameter was removed, otherwise null. 248 133 */ 249 public function remove($name, $ns = null) 250 { 251 if (!$ns)