dms/dms-filter
最新稳定版本:v6.0.0
Composer 安装命令:
composer require dms/dms-filter
包简介
DMS Filter provides Annotation based entity filtering.
README 文档
README
This library provides a service that can be used to filter object values based on annotations
Install
Use composer to add DMS\Filter to your app
composer require dms/dms-filter
Usage
Your Entity:
<?php namespace App\Entity; //Import Attributes use DMS\Filter\Rules as Filter; class User { #[Filter\StripTags] #[Filter\Trim] #[Filter\StripNewlines] public string $name; #[Filter\StripTags] #[Filter\Trim] #[Filter\StripNewlines] public string $email; } ?>
Filtering:
<?php //Load AttributeLoader $loader = new Mapping\Loader\AttributeLoader(); //Get a MetadataFactory $metadataFactory = new Mapping\ClassMetadataFactory($loader); //Get a FilterLoader $filterLoader = new \DMS\Filter\Filters\Loader\FilterLoader(); //Get a Filter $filter = new DMS\Filter\Filter($metadataFactory, $filterLoader); //Get your Entity $user = new App\Entity\User(); $user->name = "My <b>name</b>"; $user->email = " email@mail.com"; //Filter you entity $filter->filterEntity($user); echo $user->name; //"My name" echo $user->email; //"email@mail.com" ?>
Contributing
Feel free to send pull requests, just follow these guides:
- Fork
- Code
- Test
- Just create FilterTestCase and run
phpunit
- Just create FilterTestCase and run
- Submit PR
Credits
This library is inspired by the Symfony 2 Validator component and is meant to work alongside it.
Symfony Validator: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator
统计信息
- 总下载量: 468.39k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 96
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-03-16