Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rdohms/DMS-Filter
Library that offers Input Filtering based on Annotations for use with Objects. Check out 2.dev for 2.0 pre-release.
https://github.com/rdohms/DMS-Filter
annotations filtering hacktoberfest security
Last synced: about 1 month ago
JSON representation
Library that offers Input Filtering based on Annotations for use with Objects. Check out 2.dev for 2.0 pre-release.
- Host: GitHub
- URL: https://github.com/rdohms/DMS-Filter
- Owner: rdohms
- License: mit
- Created: 2011-07-05T19:16:57.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2023-09-26T16:05:35.000Z (9 months ago)
- Last Synced: 2024-05-09T05:41:06.550Z (about 1 month ago)
- Topics: annotations, filtering, hacktoberfest, security
- Language: PHP
- Homepage: http://doh.ms/project/list
- Size: 1.35 MB
- Stars: 94
- Watchers: 6
- Forks: 19
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Lists
- awesome-php - rdohms/DMS-Filter - 一个基于标注的过滤库 (过滤和验证( Filtering ang Validation ))
- awesome-php-cn - 官网
- awesome-php - DMS Filter - 一个基于标注的过滤库 (过滤和验证( Filtering ang Validation ))
- awesome-php - DMS Filter - An annotation filtering library. (Filtering and Validation)
- awesome-php - DMS Filter - 一个基于标注的过滤库 (URL)
- awesome-php - DMS Filter - An annotation filtering library. (Filtering and Validation)
- awesome-php-cn - 官网
README
# DMS Filter Component
This library provides a service that can be used to filter object values based on annotations
[![Latest Stable Version](https://poser.pugx.org/dms/dms-filter/v/stable.png)](https://packagist.org/packages/dms/dms-filter) [![Total Downloads](https://poser.pugx.org/dms/dms-filter/downloads.png)](https://packagist.org/packages/dms/dms-filter) [![Latest Unstable Version](https://poser.pugx.org/dms/dms-filter/v/unstable.png)](https://packagist.org/packages/dms/dms-filter) [![License](https://poser.pugx.org/dms/dms-filter/license.png)](https://packagist.org/packages/dms/dms-filter) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/bb7f41c3-ee7c-4473-8fbf-806453a9e899/mini.png)](https://insight.sensiolabs.com/projects/bb7f41c3-ee7c-4473-8fbf-806453a9e899) [![Build Status](https://travis-ci.org/rdohms/dms-filter.png?branch=master)](https://travis-ci.org/rdohms/dms-filter)![Unit Tests](https://github.com/rdohms/dms-filter/workflows/Unit%20Tests/badge.svg)
## Install
Use composer to add DMS\Filter to your app
`composer require dms/dms-filter`
## Usage
### Annotation way
Your Entity:
```php
```
Filtering:
```php
setEnableParsePhpImports(true);//Load AnnotationLoader
$loader = new Mapping\Loader\AnnotationLoader($reader);
$this->loader = $loader;//Get a MetadataFactory
$metadataFactory = new Mapping\ClassMetadataFactory($loader);//Get a Filter
$filter = new DMS\Filter\Filter($metadataFactory);//Get your Entity
$user = new App\Entity\User();
$user->name = "My name";
$user->email = " [email protected]";//Filter you entity
$filter->filter($user);echo $user->name; //"My name"
echo $user->email; //"[email protected]"
?>
```Full example: https://gist.github.com/1098352
### Attribute way
Your Entity:
```php
```
Filtering:
```php
loader = $loader;//Get a MetadataFactory
$metadataFactory = new Mapping\ClassMetadataFactory($loader);//Get a Filter
$filter = new DMS\Filter\Filter($metadataFactory);//Get your Entity
$user = new App\Entity\User();
$user->name = "My name";
$user->email = " [email protected]";//Filter you entity
$filter->filter($user);echo $user->name; //"My name"
echo $user->email; //"[email protected]"
?>
```## Dependencies
This package relies on these external libraries:
* Doctrine Annotations
## Contributing
Feel free to send pull requests, just follow these guides:
* Fork
* Code
* Test
* Just create FilterTestCase and run `phpunit`
* Submit PR## Credits
This library is inspired by the Symfony 2 Validator component and is meant to work alongside it.
Symfony 2 Validator: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator