Skip to content

Commit

Permalink
Merge pull request #302 from igordeveloper/master
Browse files Browse the repository at this point in the history
Release 6.0.0
  • Loading branch information
rdohms authored Sep 28, 2024
2 parents 8be6d6e + 7e98f79 commit 122484a
Show file tree
Hide file tree
Showing 24 changed files with 149 additions and 5,697 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
php-version: 8.2
coverage: pcov
tools: composer, cs2pr

- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

strategy:
matrix:
php: [7.4, 8.0]
php: [8.2, 8.3]
dependency-version: [prefer-lowest, prefer-stable]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }}
Expand All @@ -30,7 +30,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
coverage: pcov
tools: composer

- name: Install dependencies
Expand Down
72 changes: 28 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Option A) Use Composer.

Add this to your `AppKernel.php`

new DMS\Bundle\FilterBundle\DMSFilterBundle(),
DMS\Bundle\FilterBundle\DMSFilterBundle::class => ['all' => true]

### 3. Configure

Expand All @@ -31,58 +31,47 @@ This is the default behaviour, if you want to disable it add this to your `confi

### Adding Annotations

To add annotations to your entity, import the namespace and add them like this:
To add attributes to your entity, import the namespace and add them like this:

```php
<?php

namespace App\Entity;

//Import Annotations
//Import Attributes
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;

#[Filter\StripTags]
#[Filter\Trim]
#[Filter\StripNewlines]
public string $name;

#[Filter\StripTags]
#[Filter\Trim]
#[Filter\StripNewlines]
public string $email;
}
```
### Manual Filtering

Use the `dms.filter` service along with annotations in the Entity to filter data.
Use the `dms.filter.inner.filter` service along with attributes in the Entity to filter data.

```php
public function indexAction()
{

$entity = new \Acme\DemoBundle\Entity\SampleEntity();
$entity->name = "My <b>name</b>";
$entity->email = " [email protected]";

$oldEntity = clone $entity;
public function userAction(#[Autowire(service: 'dms.filter.inner.filter')] Filter $filter): Response
{
$user = new User();
$user->setName("My <b>name</b>");
$user->setEmail(" [email protected]");

$filterService = $this->get('dms.filter');
$filterService->filterEntity($entity);
//Get a Filter
$newUser = $filter->filterEntity($car);

return array('entity' => $entity, "old" => $oldEntity);
}
return new Response(
$newUser->getModel()
);
}
```

### Auto filtering
Expand Down Expand Up @@ -123,20 +112,16 @@ See below the usage example of the annotation, it takes 2 options: `service` and

namespace App\Entity;

//Import Annotations
//Import Atributes
use DMS\Filter\Rules as Filter;

//Import Symfony Rules
use DMS\Bundle\FilterBundle\Rule as SfFilter;

class User
{
/**
* @Filter\StripTags()
* @SfFilter\Service(service="dms.sample", method="filterIt")
*
* @var string
*/
#[Filter\StripTags]
#[SfFilter\Service(service: 'dms.sample', method: 'filterIt')]
public $name;
}
```
Expand All @@ -145,8 +130,7 @@ The `filterIt` method can have any name, but it must take one paramter (the valu

## Compatibility

This is compatible with Symfony 2.8 and above, including 3.0.
For Symfony 2.3+ support use "^2.0".
This is compatible with Symfony 6.4 and above and PHP 8.2 and above

## Contributing

Expand Down
19 changes: 9 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
],

"require": {
"php": "^7.4 || ^8.0",
"dms/dms-filter": "^2.0 | ^3.0 | ^4.0",
"symfony/config": "^4.4 | ^5.0",
"symfony/yaml": "^4.4 | ^5.0",
"symfony/framework-bundle": "^4.4 | ^5.0",
"symfony/form": "^4.4 | ^5.0"
"php": "^8.2",
"dms/dms-filter": "^6.0",
"symfony/config": "^6.4 | ^7.0",
"symfony/yaml": "^6.4 | ^7.0",
"symfony/framework-bundle": "^6.4 | ^7.0",
"symfony/form": "^6.4 | ^7.0"
},

"autoload": {
Expand All @@ -28,9 +28,8 @@
}
},
"require-dev": {
"phpunit/phpunit": "^9",
"phpspec/prophecy-phpunit": "^2.0",
"doctrine/annotations": "^1.13",
"dms/coding-standard":"^8"
"ext-pcov": "*",
"phpunit/phpunit": "^11",
"squizlabs/php_codesniffer": "3.*"
}
}
Loading

0 comments on commit 122484a

Please sign in to comment.