sfOutputEscaperGetterDecorator.class.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 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. * Abstract output escaping decorator class for "getter" objects.
  11. *
  12. * @see sfOutputEscaper
  13. * @package symfony
  14. * @subpackage view
  15. * @author Mike Squire <mike@somosis.co.uk>
  16. * @version SVN: $Id: sfOutputEscaperGetterDecorator.class.php 9047 2008-05-19 08:43:05Z FabianLange $
  17. */
  18. abstract class sfOutputEscaperGetterDecorator extends sfOutputEscaper
  19. {
  20. /**
  21. * Returns the raw, unescaped value associated with the key supplied.
  22. *
  23. * The key might be an index into an array or a value to be passed to the
  24. * decorated object's get() method.
  25. *
  26. * @param string $key The key to retrieve
  27. *
  28. * @return mixed The value
  29. */
  30. public abstract function getRaw($key);
  31. /**
  32. * Returns the escaped value associated with the key supplied.
  33. *
  34. * Typically (using this implementation) the raw value is obtained using the
  35. * {@link getRaw()} method, escaped and the result returned.
  36. *
  37. * @param string $key The key to retieve
  38. * @param string $escapingMethod The escaping method (a PHP function) to use
  39. *
  40. * @return mixed The escaped value
  41. */
  42. public function get($key, $escapingMethod = null)
  43. {
  44. if (!$escapingMethod)
  45. {
  46. $escapingMethod = $this->escapingMethod;
  47. }
  48. return sfOutputEscaper::escape($escapingMethod, $this->getRaw($key));
  49. }
  50. }