Permalink
Browse files

updating Filter to just inject the Config instance

  • Loading branch information...
1 parent d52033f commit 25c07b47e813aab42905bd64e41a2bb7fc542c65 @enygma committed Aug 10, 2012
Showing with 32 additions and 1 deletion.
  1. +32 −1 Shield/Filter.php
View
33 Shield/Filter.php
@@ -11,6 +11,17 @@ class Filter extends Base
private $filters = array();
/**
+ * Config instance
+ * @var object
+ */
+ private $config = null;
+
+ public function __construct(\Shield\Config $config)
+ {
+ $this->config = $config;
+ }
+
+ /**
* Add a new filter
*
* @param string $name Name of the field
@@ -45,12 +56,20 @@ public function get($name)
return $func;
}
+ /**
+ * Filter the given property (name) with the given value
+ *
+ * @param string $name Name of property
+ * @param mixed $value Value to filter
+ *
+ * @return mixed $value Filtered value
+ */
public function filter($name, $value)
{
$filters = $this->get($name);
if (count($filters) == 0) {
- $filters = array('striptags');
+ $filters = array('htmlentities');
}
foreach ($filters as $filter) {
if ($filter instanceof \Closure) {
@@ -92,6 +111,18 @@ private function filterStriptags($value)
}
/**
+ * Apply the htmlentities method on the value
+ *
+ * @param string $value Value to filter
+ *
+ * @return string Filtered result
+ */
+ private function filterHtmlentities($value)
+ {
+ return htmlentities($value);
+ }
+
+ /**
* Filter the value to see if it's an integer
*
* @param string $value Value to be filtered

0 comments on commit 25c07b4

Please sign in to comment.