Skip to content

Commit

Permalink
[Filter] Updating README example with more detail
Browse files Browse the repository at this point in the history
  • Loading branch information
rdohms committed Jul 21, 2011
1 parent 8bfbd3f commit e8369b3
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions README.md
Expand Up @@ -4,6 +4,43 @@ This library provides a service that can be used to filter object values based o


## Usage ## 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
<?php <?php
//Get Doctrine Reader //Get Doctrine Reader
Expand All @@ -20,10 +57,21 @@ This library provides a service that can be used to filter object values based o
//Get a Filter //Get a Filter
$filter = new DMS\Filter\Filter($metadataFactory); $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 ## Dependencies


Expand Down

0 comments on commit e8369b3

Please sign in to comment.