Permalink
Browse files

[Filter] Updating README example with more detail

  • Loading branch information...
1 parent 8bfbd3f commit e8369b3b0a656472102fc55b1e0b5f8b0d821136 @rdohms committed Jul 21, 2011
Showing with 51 additions and 3 deletions.
  1. +51 −3 README.md
View
@@ -4,6 +4,43 @@ This library provides a service that can be used to filter object values based o
## Usage
+Your Entity:
+
+```php
+<?php
+
+namespace App\Entity;
+
+//Import Annotations
+use DMS\Filter\Rules as Filter;
+
+class User
+{
+
+ /**
+ * @Filter\StripTags()
+ * @Filter\Trim()
+ * @Filter\StripNewlines()
+ *
+ * @var string
+ */
+ public $name;
+
+ /**
+ * @Filter\StripTags()
+ * @Filter\Trim()
+ * @Filter\StripNewlines()
+ *
+ * @var string
+ */
+ public $email;
+
+}
+?>
+```
+
+Filtering:
+
```php
<?php
//Get Doctrine Reader
@@ -20,10 +57,21 @@ This library provides a service that can be used to filter object values based o
//Get a Filter
$filter = new DMS\Filter\Filter($metadataFactory);
- //Filter object
- $filter->filter($object);
+
+ //Get your Entity
+ $user = new App\Entity\User();
+ $user->name = "My <b>name</b>";
+ $user->email = " email@mail.com";
+
+ //Filter you entity
+ $filter->filter($user);
+
+ echo $user->name; //"My name"
+ echo $user->email; //"email@mail.com"
?>
-```
+```
+
+Full example: https://gist.github.com/1098352
## Dependencies

0 comments on commit e8369b3

Please sign in to comment.