[OutputEscaper] added SafeDecoratorInterface

This commit is contained in:
Fabien Potencier 2010-09-28 22:19:17 +02:00
parent 7650dd708f
commit 6aa190b2a6
3 changed files with 28 additions and 7 deletions

View File

@ -118,18 +118,18 @@ abstract class Escaper
return $copy;
}
if (self::isClassMarkedAsSafe(get_class($value))) {
// the class or one of its children is marked as safe
// return the unescaped object
return $value;
}
if ($value instanceof SafeDecorator) {
// do not escape objects marked as safe
// return the original object
return $value->getValue();
}
if (self::isClassMarkedAsSafe(get_class($value)) || $value instanceof SafeDecoratorInterface) {
// the class or one of its children is marked as safe
// return the unescaped object
return $value;
}
if ($value instanceof \Traversable) {
return new IteratorDecorator($escaper, $value);
}

View File

@ -16,7 +16,7 @@ namespace Symfony\Component\OutputEscaper;
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class SafeDecorator extends \ArrayIterator
class SafeDecorator extends \ArrayIterator implements SafeDecoratorInterface
{
protected $value;

View File

@ -0,0 +1,21 @@
<?php
namespace Symfony\Component\OutputEscaper;
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Marks a class as being safe for output.
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
interface SafeDecoratorInterface
{
}