Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OutputEscaper] refactored the component
- Loading branch information
Showing
11 changed files
with
208 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?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. | ||
*/ | ||
|
||
/** | ||
* Abstract class that provides an interface for output escaping. | ||
* | ||
* @author Fabien Potencier <fabien.potencier@symfony-project.com> | ||
* @author Mike Squire <mike@somosis.co.uk> | ||
*/ | ||
abstract class BaseEscaper | ||
{ | ||
/** | ||
* The value that is to be escaped. | ||
*/ | ||
protected $value; | ||
|
||
/** | ||
* The escaper (a PHP callable or a named escaper) that is going to be applied to the value and its children. | ||
*/ | ||
protected $escaper; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* Since BaseEscaper is an abstract class, instances cannot be created | ||
* directly but the constructor will be inherited by sub-classes. | ||
* | ||
* @param mixed $escaper The escaping method (a PHP callable or a named escaper) | ||
* @param string $value Escaping value | ||
*/ | ||
public function __construct($escaper, $value) | ||
{ | ||
$this->escaper = $escaper; | ||
$this->value = $value; | ||
} | ||
|
||
/** | ||
* Sets the default escaper to use. | ||
* | ||
* @param mixed $escaper The escaping method (a PHP callable or a named escaper) | ||
*/ | ||
public function setEscaper($escaper) | ||
{ | ||
$this->escaper = $escaper; | ||
} | ||
|
||
/** | ||
* Returns the raw value associated with this instance. | ||
* | ||
* Concrete instances of BaseEscaper classes decorate a value which is | ||
* stored by the constructor. This returns that original, unescaped, value. | ||
* | ||
* @return mixed The original value used to construct the decorator | ||
*/ | ||
public function getRawValue() | ||
{ | ||
return $this->value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.