TYPO3 CMS  TYPO3_6-2
FilterUtility.php
Go to the documentation of this file.
1 <?php
3 
23 
29  protected $filters = array();
30 
37  public function __construct() {
38  $removeXssFilter = $this->makeFilter('removeXss');
39  $this->addFilter($removeXssFilter);
40  }
41 
48  public function addFilter(\TYPO3\CMS\Form\Filter\FilterInterface $filter) {
49  $this->filters[] = $filter;
50  return $this;
51  }
52 
61  public function makeFilter($class, array $arguments = NULL) {
62  return self::createFilter($class, $arguments);
63  }
64 
71  public function filter($value) {
72  if (!empty($this->filters)) {
74  foreach ($this->filters as $filter) {
75  $value = $filter->filter($value);
76  }
77  }
78  return $value;
79  }
80 
89  static public function get($class, $value, array $arguments = array()) {
90  return self::createFilter($class, $arguments)->filter($value);
91  }
92 
101  static public function createFilter($class, array $arguments = NULL) {
102  $class = strtolower((string) $class);
103  $className = 'TYPO3\\CMS\\Form\\Filter\\' . ucfirst($class) . 'Filter';
104  if (is_null($arguments)) {
106  } else {
107  $filter = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className, $arguments);
108  }
109  return $filter;
110  }
111 
112 }
addFilter(\TYPO3\CMS\Form\Filter\FilterInterface $filter)
makeFilter($class, array $arguments=NULL)
static createFilter($class, array $arguments=NULL)