{"id":16960722,"url":"https://github.com/bukashk0zzz/filterbundle","last_synced_at":"2025-03-15T14:30:40.659Z","repository":{"id":51234583,"uuid":"54015646","full_name":"Bukashk0zzz/FilterBundle","owner":"Bukashk0zzz","description":"Symfony filtering bundle","archived":false,"fork":false,"pushed_at":"2024-04-18T20:33:52.000Z","size":111,"stargazers_count":24,"open_issues_count":3,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-24T13:55:37.956Z","etag":null,"topics":["bundle","filter","php","symfony","symfony-bundle","symfony3-bundle","zend-filter"],"latest_commit_sha":null,"homepage":null,"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/Bukashk0zzz.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-16T08:52:30.000Z","updated_at":"2024-06-20T23:25:11.083Z","dependencies_parsed_at":"2024-06-20T23:25:06.552Z","dependency_job_id":"023474a8-3295-4d05-ad2f-9735ded95ea9","html_url":"https://github.com/Bukashk0zzz/FilterBundle","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bukashk0zzz%2FFilterBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bukashk0zzz%2FFilterBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bukashk0zzz%2FFilterBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bukashk0zzz%2FFilterBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bukashk0zzz","download_url":"https://codeload.github.com/Bukashk0zzz/FilterBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243742597,"owners_count":20340669,"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":["bundle","filter","php","symfony","symfony-bundle","symfony3-bundle","zend-filter"],"created_at":"2024-10-13T22:49:53.542Z","updated_at":"2025-03-15T14:30:40.178Z","avatar_url":"https://github.com/Bukashk0zzz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Symfony Filter Bundle\n\n[![Code Coverage](https://img.shields.io/codecov/c/github/Bukashk0zzz/FilterBundle.svg?style=flat-square)](https://codecov.io/github/Bukashk0zzz/FilterBundle)\n[![License](https://img.shields.io/packagist/l/Bukashk0zzz/filter-bundle.svg?style=flat-square)](https://packagist.org/packages/Bukashk0zzz/filter-bundle)\n[![Latest Stable Version](https://img.shields.io/packagist/v/Bukashk0zzz/filter-bundle.svg?style=flat-square)](https://packagist.org/packages/Bukashk0zzz/filter-bundle)\n[![Total Downloads](https://img.shields.io/packagist/dt/Bukashk0zzz/filter-bundle.svg?style=flat-square)](https://packagist.org/packages/Bukashk0zzz/filter-bundle)\n\nAbout\n-----\nThis bundle add a service that can be used to filter object values based on annotations. [Laminas filter](https://github.com/laminas/laminas-filter) old [ZendFilters](https://github.com/zendframework/zend-filter) used for filtering.\nAlso bundle can filter your forms if it finds a annotated entity attached. If `auto_filter_forms` enabled entities will be filtered before they are validated.\n[Laminas filters doc](https://docs.laminas.dev/laminas-filter/)\n\nInstallation Symfony Flex\n------------\n\n```bash\ncomposer config extra.symfony.allow-contrib true\ncomposer require bukashk0zzz/filter-bundle\n```\n\nInstallation without Symfony Flex\n------------\n\n```bash\ncomposer require bukashk0zzz/filter-bundle\n```\n\nAdd the bundle to `app/AppKernel.php`\n\n```php\n$bundles = array(\n\t// ... other bundles\n\tnew Bukashk0zzz\\FilterBundle\\Bukashk0zzzFilterBundle(),\n);\n```\n\nConfiguration\n-------------\n\nAdd this to your `config.yml`:\n\n```yaml\nbukashk0zzz_filter:\n    # Enable if you need auto filtering form data before constraint(Validation) check\n    auto_filter_forms: false\n```\n\nUsage\n------\n\nBundle provides one annotation which allow filter fields in your entities.\n\nAdd the next class to the `use` section of your entity class.\n\n```php\nuse Bukashk0zzz\\FilterBundle\\Annotation\\FilterAnnotation as Filter;\n```\n\nAnnotation `@Filter` has one required option *filter* which value should be name of Laminas filter class.\nIt can be set like this `@Filter(\"StringTrim\")` or `@Filter(filter=\"AppBundle\\Filter\\MyCustomFilter\")`.\n\n`AppBundle\\Filter\\MyCustomFilter` - in this example, must be class that extends `\\Laminas\\Filter\\AbstractFilter`\n\nAlso there is one not required option `options` - it must be array type and will pass to Laminas filter using `setOptions` method from Laminas filter. \n\nExample entity\n--------------\n\n```php\n\u003c?php\nnamespace AppBundle\\Entity;\n\nuse Bukashk0zzz\\FilterBundle\\Annotation\\FilterAnnotation as Filter;\n\n/**\n * User Entity\n */\nclass User\n{\n    #[Filter(parameters: [\n        'filter' =\u003e 'StripTags',\n        'options' =\u003e ['allowTags' =\u003e 'br']\n    ])]\n    #[Filter(parameters: ['filter' =\u003e 'StringTrim'])]\n    #[Filter(parameters: ['filter' =\u003e 'StripNewlines'])]\n    protected $name;\n\n    #[Filter(parameters: ['filter' =\u003e 'StripTags'])]\n    #[Filter(parameters: ['filter' =\u003e 'StringTrim'])]\n    #[Filter(parameters: ['filter' =\u003e 'AppBundle\\Filter\\MyCustomFilter'])]\n    protected $about;\n}\n\n```\n\nUsing filter service\n--------------------\n\nUse the `bukashk0zzz_filter.filter` service along with annotations in the Entity to filter data.\n\n```php\npublic function indexAction()\n{\n\n    $entity = new \\Acme\\DemoBundle\\Entity\\SampleEntity();\n    $entity-\u003ename = \"My \u003cb\u003ename\u003c/b\u003e\";\n    $entity-\u003eemail = \" email@mail.com\";\n\n    $filterService = $this-\u003eget('bukashk0zzz_filter.filter');\n    $filterService-\u003efilterEntity($entity);\n\n    return ['entity' =\u003e $entity];\n}\n```\n\nCopyright / License\n-------------------\n\nSee [LICENSE](https://github.com/bukashk0zzz/FilterBundle/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbukashk0zzz%2Ffilterbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbukashk0zzz%2Ffilterbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbukashk0zzz%2Ffilterbundle/lists"}