{"id":14984063,"url":"https://github.com/rdohms/dms-filter-bundle","last_synced_at":"2025-04-06T07:12:13.067Z","repository":{"id":2192376,"uuid":"3140433","full_name":"rdohms/dms-filter-bundle","owner":"rdohms","description":"Provides a FilterService for Symfony to allow users to implement input filtering in entities using Annotations","archived":false,"fork":false,"pushed_at":"2023-01-25T08:03:52.000Z","size":323,"stargazers_count":77,"open_issues_count":8,"forks_count":23,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-02T01:14:32.826Z","etag":null,"topics":["filtering","hacktoberfest","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rdohms.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-09T21:51:24.000Z","updated_at":"2023-10-08T15:58:46.000Z","dependencies_parsed_at":"2023-02-14T05:47:15.508Z","dependency_job_id":null,"html_url":"https://github.com/rdohms/dms-filter-bundle","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdohms%2Fdms-filter-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdohms%2Fdms-filter-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdohms%2Fdms-filter-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdohms%2Fdms-filter-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rdohms","download_url":"https://codeload.github.com/rdohms/dms-filter-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445671,"owners_count":20939958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filtering","hacktoberfest","symfony","symfony-bundle"],"created_at":"2024-09-24T14:08:23.601Z","updated_at":"2025-04-06T07:12:13.045Z","avatar_url":"https://github.com/rdohms.png","language":"PHP","funding_links":[],"categories":["Validation"],"sub_categories":[],"readme":"# DMS Filter Bundle\n\nThis bundle makes DMS/Filter available for use in your application for input filtering.\n\nCurrent Status: [![Build Status](https://travis-ci.org/rdohms/dms-filter-bundle.png?branch=2.dev)](https://travis-ci.org/rdohms/dms-filter-bundle) [![Dependency Status](https://www.versioneye.com/php/dms:dms-filter-bundle/1.1.1/badge.png)](https://www.versioneye.com/php/dms:dms-filter-bundle/1.1.1)\n\n## Install\n\n### 1. Import libraries\n\nOption A) Use Composer.\n\n    composer require dms/dms-filter-bundle\n\n### 2. Enable Bundle\n\nAdd this to your `config/bundles.php`\n\n    DMS\\Bundle\\FilterBundle\\DMSFilterBundle::class =\u003e ['all' =\u003e true]\n\n### 3. Configure\n\nThis bundle can now automatically filter your forms if it finds a annotated entity attached.\n\nThis is the default behaviour, if you want to disable it add this to your `config.yml`\n\n    dms_filter:\n        auto_filter_forms: false\n\n## Usage\n\n### Adding Annotations\n\nTo add attributes to your entity, import the namespace and add them like this:\n\n```php\n\u003c?php\n\nnamespace App\\Entity;\n\n//Import Attributes\nuse DMS\\Filter\\Rules as Filter;\n\nclass User\n{\n    #[Filter\\StripTags]\n    #[Filter\\Trim]\n    #[Filter\\StripNewlines]\n    public string $name;\n\n    #[Filter\\StripTags]\n    #[Filter\\Trim]\n    #[Filter\\StripNewlines]\n    public string $email;\n}\n```\n### Manual Filtering\n\nUse the `dms.filter.inner.filter` service along with attributes in the Entity to filter data.\n\n```php\n    public function userAction(#[Autowire(service: 'dms.filter.inner.filter')] Filter $filter): Response\n    {\n        $user = new User();\n        $user-\u003esetName(\"My \u003cb\u003ename\u003c/b\u003e\");\n        $user-\u003esetEmail(\" email@mail.com\");\n\n        //Get a Filter\n        $newUser = $filter-\u003efilterEntity($car);\n\n        return new Response(\n            $newUser-\u003egetModel()\n        );\n    }\n```\n\n### Auto filtering\n\nThis bundle can now automatically filter your forms if it finds a annotated entity attached. If enabled entities will be filtered before they are validated.\n\n### Cascade Filtering\n\nThis Bundle automatically cascades filtering into all embedded forms that return valid entities. If you wish child\nentities to be ignored, set the `cascade_filter` option on the form to false.\n\n\n```php\nclass TaskType extends AbstractType\n{\n    // ...\n\n    public function setDefaultOptions(OptionsResolverInterface $resolver)\n    {\n        $resolver-\u003esetDefaults(array(\n                'cascade_filter' =\u003e false,\n            ));\n    }\n\n    // ...\n}\n```\n\n## Service based method\n\nIf you need to filter content using a method in a service, you do not need to create your own Annotations, you can\nsimply use the Service Filter, designed specifically for Symfony Services.\n\nSee below the usage example of the annotation, it takes 2 options: `service` and `method`.\n\n```php\n\u003c?php\n\nnamespace App\\Entity;\n\n//Import Atributes\nuse DMS\\Filter\\Rules as Filter;\n\n//Import Symfony Rules\nuse DMS\\Bundle\\FilterBundle\\Rule as SfFilter;\n\nclass User\n{\n    #[Filter\\StripTags]\n    #[SfFilter\\Service(service: 'dms.sample', method: 'filterIt')]\n    public $name;\n}\n```\n\nThe `filterIt` method can have any name, but it must take one paramter (the value) and return the filtered value.\n\n## Compatibility\n\nThis is compatible with Symfony 6.4 and above and PHP 8.2 and above\n\n## Contributing\n\nGiven you have composer, cloned the project repository and have a terminal open on it:\n\n    composer.phar install --prefer-source --dev\n    vendor/bin/phpunit\n    vendor/bin/phpcs\n\nThe tests should be passing and you are ready to make contributions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdohms%2Fdms-filter-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frdohms%2Fdms-filter-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdohms%2Fdms-filter-bundle/lists"}