Skip to content

Commit

Permalink
[OutputEscaper] added SafeDecoratorInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Sep 28, 2010
1 parent 7650dd7 commit 6aa190b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/Symfony/Component/OutputEscaper/Escaper.php
Expand Up @@ -118,18 +118,18 @@ static public function escape($escaper, $value)
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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/OutputEscaper/SafeDecorator.php
Expand Up @@ -16,7 +16,7 @@
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class SafeDecorator extends \ArrayIterator
class SafeDecorator extends \ArrayIterator implements SafeDecoratorInterface
{
protected $value;

Expand Down
21 changes: 21 additions & 0 deletions src/Symfony/Component/OutputEscaper/SafeDecoratorInterface.php
@@ -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
{
}

0 comments on commit 6aa190b

Please sign in to comment.