sfOutputEscaperSafe.class.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * Marks a variable as being safe for output.
  11. *
  12. * @package symfony
  13. * @subpackage view
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfOutputEscaperSafe.class.php 16553 2009-03-24 16:49:06Z Kris.Wallsmith $
  16. */
  17. class sfOutputEscaperSafe extends ArrayIterator
  18. {
  19. protected
  20. $value = null;
  21. /**
  22. * Constructor.
  23. *
  24. * @param mixed $value The value to mark as safe
  25. */
  26. public function __construct($value)
  27. {
  28. $this->value = $value;
  29. if (is_array($value) || is_object($value))
  30. {
  31. parent::__construct($value);
  32. }
  33. }
  34. public function __toString()
  35. {
  36. return (string) $this->value;
  37. }
  38. public function __get($key)
  39. {
  40. return $this->value->$key;
  41. }
  42. public function __set($key, $value)
  43. {
  44. $this->value->$key = $value;
  45. }
  46. public function __call($method, $arguments)
  47. {
  48. return call_user_func_array(array($this->value, $method), $arguments);
  49. }
  50. public function __isset($key)
  51. {
  52. return isset($this->value->$key);
  53. }
  54. public function __unset($key)
  55. {
  56. unset($this->value->$key);
  57. }
  58. /**
  59. * Returns the embedded value.
  60. *
  61. * @return mixed The embedded value
  62. */
  63. public function getValue()
  64. {
  65. return $this->value;
  66. }
  67. }