Skip to content

Commit a168154

Browse files
authored
Allow EasyAdmin 2.2.0 and upper (#166)
* Allow Sf 5.0 + EA >= 2.2 * Rename parameter for request list filters * Targeting v3.0.0 instead of v2.2.0 * Remove role based menu filtering (replaced by native one) * CI get PHPStan level 5 analysis * default values for tests * Min version for EasyAdmin is 2.2.2 (with menu permissions)
1 parent 2a6cd48 commit a168154

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+392
-721
lines changed

.travis.yml

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,65 @@
11
language: php
2-
dist: precise
32
sudo: false
4-
git:
5-
depth: 1
63

74
cache:
85
directories:
9-
- $HOME/.composer/cache
10-
- $HOME/.app/cache
6+
- $HOME/.composer/cache/files
7+
- $HOME/symfony-bridge/.phpunit
118

129
env:
1310
global:
14-
- deps="no"
15-
- SYMFONY_VERSION=""
16-
- CHECK_PHP_SYNTAX="no"
17-
- SYMFONY_DEPRECATIONS_HELPER="weak"
1811
- ENABLE_CODE_COVERAGE="false"
12+
- PHPUNIT_FLAGS="-v"
13+
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"
14+
- SYMFONY_DEPRECATIONS_HELPER="999999"
1915

2016
matrix:
2117
fast_finish: true
2218
include:
23-
# bleeding edge (unreleased dev versions where failures are allowed)
24-
- php: nightly
25-
env:
26-
- STABILITY=dev
27-
- SYMFONY_VERSION="4.*"
28-
# stable (most recent stable versions)
19+
- php: 7.1
20+
env: CHECK_PHP_SYNTAX="true"
21+
COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER=weak
22+
SYMFONY_VERSION="4.2.*"
23+
TWIG_VERSION="^2.4"
24+
2925
- php: 7.2
30-
env:
31-
- SYMFONY_VERSION="4.1.*"
32-
- TWIG_VERSION="^2.4"
33-
- ENABLE_CODE_COVERAGE="true"
26+
env: COMPOSER_FLAGS="--ignore-platform-reqs"
27+
28+
- php: 7.3
29+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER=weak
30+
SYMFONY_VERSION="4.2.*"
31+
TWIG_VERSION="^2.4"
32+
ENABLE_CODE_COVERAGE="true"
33+
34+
# Latest commit to master
35+
- php: nightly
36+
env: COMPOSER_FLAGS="--ignore-platform-reqs" SYMFONY_PHPUNIT_VERSION=8.4
3437
allow_failures:
35-
# code coverage is very slow; allow a failure to get the Travis result early
38+
# Dev-master is allowed to fail.
3639
- php: nightly
3740

3841
before_install:
39-
- stty cols 120
40-
- INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
41-
- echo memory_limit = -1 >> $INI_FILE
42-
- echo session.gc_probability = 0 >> $INI_FILE
43-
- echo opcache.enable_cli = 1 >> $INI_FILE
44-
- if [[ "$SYMFONY_VERSION" == 3.3.* ]]; then export SYMFONY_DEPRECATIONS_HELPER="strict"; fi;
42+
- phpenv config-rm xdebug.ini || true
43+
- if [[ "$CHECK_PHP_SYNTAX" == "true" ]]; then wget https://cs.symfony.com/download/php-cs-fixer-v2.phar -O php-cs-fixer; fi
44+
- phpenv global 7.2; composer global require --prefer-dist --no-progress --no-scripts --no-plugins symfony/flex dev-master; phpenv global $TRAVIS_PHP_VERSION
4545
- if [[ "$ENABLE_CODE_COVERAGE" != "true" && "$TRAVIS_EVENT_TYPE" != "cron" ]]; then rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;
46-
- composer self-update
47-
- if [[ "$SYMFONY_VERSION" != "" ]]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;
48-
- if [[ "$TWIG_VERSION" != "" ]]; then composer require "twig/twig:${TWIG_VERSION}" --no-update; fi;
49-
- if [[ "$STABILITY" != "" ]]; then composer config minimum-stability $STABILITY; fi
5046

5147
install:
52-
- if [[ "$CHECK_PHP_SYNTAX" == "yes" ]]; then composer require --dev --no-update friendsofphp/php-cs-fixer; fi;
53-
- composer update --prefer-dist --no-interaction --no-suggest --no-progress --ansi $COMPOSER_FLAGS
48+
- composer update $COMPOSER_FLAGS --no-interaction
49+
- phpenv global 7.2; ./vendor/bin/simple-phpunit install; phpenv global $TRAVIS_PHP_VERSION
5450
- if [[ "$ENABLE_CODE_COVERAGE" == "true" ]]; then composer require --dev php-coveralls/php-coveralls; fi
5551

5652
script:
57-
- if [[ $ENABLE_CODE_COVERAGE == "true" ]]; then vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml; else vendor/bin/phpunit; fi
53+
- composer validate --strict --no-check-lock
54+
- if [[ "$CHECK_PHP_SYNTAX" == "true" ]]; then php php-cs-fixer --no-interaction --dry-run --diff -v fix; fi
55+
# this run PHPStan level 5 static analysis
56+
- vendor/bin/phpstan analyse -c phpstan.neon --level=5 src
57+
# this checks that the Twig template files contain no syntax errors
58+
- ./tests/bin/console lint:twig "src" "tests"
59+
# this checks that the YAML config files contain no syntax errors
60+
- ./tests/bin/console lint:yaml "tests"
61+
62+
- if [[ $ENABLE_CODE_COVERAGE == "true" ]]; then vendor/bin/simple-phpunit $PHPUNIT_FLAGS --coverage-text --coverage-clover build/logs/clover.xml; else vendor/bin/simple-phpunit $PHPUNIT_FLAGS; fi
5863
- if [[ "$CHECK_PHP_SYNTAX" == "yes" ]]; then php vendor/bin/php-cs-fixer --no-interaction --dry-run --diff -v fix; fi;
5964
- if [[ "$CHECK_PHP_SYNTAX" == "yes" ]]; then mv ./.php_cs.cache $HOME/.app/cache/.php_cs.cache 2> /dev/null; fi;
6065

README.md

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ EasyAdmin Extension
55

66
EasyAdmin Extension provides some useful extensions to [EasyAdmin](https://github.com/EasyCorp/EasyAdminBundle) admin generator for Symfony.
77

8-
:exclamation: Branch `2.2.x` of this bundle requires at least __PHP 7.1__ and __Symfony 4.2__ components or stack and is suitable for EasyAdmin `^2.2.0`. It allows installation of EasyAdmin `2.2.0` or upper and Symfony 5 as well. __Extension bundle implementation of list filters is NOT COMPATIBLE with EasyAdmin dynamic list filters !__ Use extension implementation if you want to use embedded list, OR do not use embedded list.
8+
* Branch `3.x` of this bundle requires at least __PHP 7.1__ and __Symfony 4.2__ components or stack and is suitable for EasyAdmin `^2.2.2` (Versions v2.2.0 and v2.2.1 are not allowed as they don't have native menu permissions). It allows installation of EasyAdmin `2.2.0` or upper and Symfony 5 as well. __Extension bundle implementation of list filters is NOT COMPATIBLE with EasyAdmin dynamic list filters !__ That's why we introduced the following change :
9+
> :exclamation: __BC BREAK__ list filters implemented by this extension bundle now use `ext_filters` query/form parameter, as `filters` is now used by native EasyAdmin for its own implementation of dynamic list filters.
910
10-
:exclamation: Branch `2.0.x` and `2.1.x` of this bundle requires at least __PHP 7.1__ and __Symfony 4.1__ components or stack and is suitable for EasyAdmin `2.0.x` and `2.1.x`. __It does not allow installation of EasyAdmin `2.2.0` or upper !__
11+
* Branch `2.x` of this bundle requires at least __PHP 7.1__ and __Symfony 4.1__ components or stack and is suitable for EasyAdmin `2.0.x` and `2.1.x`. __It does not allow installation of EasyAdmin `2.2.0` or upper !__
1112

12-
:exclamation: Branch `1.x` of this bundle requires at least __PHP 7.0__ and __Symfony 3.0__ components or stack and is suitable for EasyAdmin `1.x`.
13+
* Branch `1.x` of this bundle requires at least __PHP 7.0__ and __Symfony 3.0__ components or stack and is suitable for EasyAdmin `1.x`.
1314

1415

1516

@@ -210,9 +211,9 @@ Available built-in operators are listed in `AlterPHP\EasyAdminExtensionBundle\Mo
210211

211212
* EasyAdmin allows filtering list with `dql_filter` configuration entry. But this is not dynamic and must be configured as an apart list in `easy_admin` configuration.*
212213

213-
This extension allows to __dynamically filter lists__ by adding `filters` parameter in the URL parameters. Having a list of books at URL `<url-to-admin>?action=list&entity=Book` with a releaseYear field, you can filter on books releasd in 2016 by requesting `<url-to-admin>?action=list&entity=Book&filters[entity.releaseDate]=2016`. It only matches exact values, but you can chain them. To request books released in 2015 and 2016, you must request `<url-to-admin>?action=list&entity=Book&filters[entity.releaseDate][]=2015&filters[entity.releaseDate][]=2016`.
214+
This extension allows to __dynamically filter lists__ by adding `ext_filters` parameter in the URL parameters. Having a list of books at URL `<url-to-admin>?action=list&entity=Book` with a releaseYear field, you can filter on books releasd in 2016 by requesting `<url-to-admin>?action=list&entity=Book&ext_filters[entity.releaseDate]=2016`. It only matches exact values, but you can chain them. To request books released in 2015 and 2016, you must request `<url-to-admin>?action=list&entity=Book&ext_filters[entity.releaseDate][]=2015&ext_filters[entity.releaseDate][]=2016`.
214215

215-
This `filters` parameter is transmitted to the referer used for post update/delete/create redirection AND for search !
216+
This `ext_filters` parameter is transmitted to the referer used for post update/delete/create redirection AND for search !
216217

217218
### Register your own form types with a short name (aliasing form types)
218219

@@ -237,7 +238,7 @@ Embedded lists are useful to show relations to en entity in its *NEW/EDIT/FORM*
237238
Available options are :
238239

239240
- `entity`: Entity config name (key under the EasyAdmin `entities` config)
240-
- `filters`: Request filters to apply on the list
241+
- `ext_filters`: Request filters to apply on the list
241242
- `hidden_fields`: List of fields (columns) to hide from list fields config
242243
- `max_results`: Number of items par page (list.max_results config is used if not defined)
243244
- `sort`: Sort to apply
@@ -266,7 +267,7 @@ easy_admin:
266267
fields:
267268
# ...
268269
- { type: group, label: Events, css_class: 'col-sm-12', icon: calendar }
269-
- { property: events, label: '', type: embedded_list, type_options: { entity: Event, filters: { 'entity.promoter': 'form:parent.data.id' } } }
270+
- { property: events, label: '', type: embedded_list, type_options: { entity: Event, ext_filters: { 'entity.promoter': 'form:parent.data.id' } } }
270271
271272
```
272273

@@ -377,17 +378,6 @@ easy_admin:
377378

378379
Entity _role_prefix_ defines all actions required roles by appending the action name to the prefix.
379380

380-
#### Hiding *not-entity-based* menu entries on __role__ option
381-
382-
```yaml
383-
easy_admin:
384-
menu:
385-
- { label: 'Administrator', role: ROLE_SUPER_ADMIN } # Hidden if user is not granted ROLE_SUPER_ADMIN
386-
- { label: 'App action', route: 'app_action', role: ROLE_ADMIN } # Hidden if user is not granted ROLE_ADMIN
387-
```
388-
389-
:warning: __Beware this ONLY HIDE the menu entry and do not secure secure access to the targeted URL/route !__
390-
391381
#### Per entity field role permissions in form
392382

393383
You can also define role permissions per entity field in a form:
@@ -494,7 +484,7 @@ Locally with Docker :
494484

495485
Locally with Docker :
496486

497-
docker-compose run --rm php /app/vendor/bin/phpstan analyse -c /app/phpstan.neon --level=6 /app/src
487+
docker-compose run --rm php /app/vendor/bin/phpstan analyse -c /app/phpstan.neon --level=5 /app/src
498488

499489
License
500490
-------

UPGRADE.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,83 @@
11
# UPGRADE guide for EasyAdminExtension bundle
22

3+
## v3.0.0
4+
5+
This version unlocks dependency to EasyAdmin by allowing __EasyAdmin ^2.2.0__. As this version of EasyAdmin introduce its own implementation of list filters (using query parameter `filter`), and considering it is not compatible with extension bundle's implementation : __I decided to rename the parameter to pass filters used by the extension__. This is an important BC BREAK.
6+
7+
### Renamed query parameter for list filters (BC break)
8+
9+
`filter` is now used by native EasyAdmin implementation. Use `ext_filters` for extension implementation (for embedded lists) !
10+
11+
__BEFORE__
12+
13+
`<url-to-admin>?action=list&entity=Book&filters[entity.releaseDate]=2016`
14+
15+
__AFTER__
16+
17+
`<url-to-admin>?action=list&entity=Book&ext_filters[entity.releaseDate]=2016`
18+
19+
20+
__BEFORE__
21+
22+
```yaml
23+
easy_admin:
24+
entities:
25+
Event:
26+
class: App\Entity\Event
27+
Promoter:
28+
class: App\Entity\Promoter
29+
form:
30+
fields:
31+
# ...
32+
- { type: group, label: Events, css_class: 'col-sm-12', icon: calendar }
33+
- { property: events, label: '', type: embedded_list, type_options: { entity: Event, filters: { 'entity.promoter': 'form:parent.data.id' } } }
34+
35+
```
36+
37+
__AFTER__
38+
39+
```yaml
40+
easy_admin:
41+
entities:
42+
Event:
43+
class: App\Entity\Event
44+
Promoter:
45+
class: App\Entity\Promoter
46+
form:
47+
fields:
48+
# ...
49+
- { type: group, label: Events, css_class: 'col-sm-12', icon: calendar }
50+
- { property: events, label: '', type: embedded_list, type_options: { entity: Event, ext_filters: { 'entity.promoter': 'form:parent.data.id' } } }
51+
52+
```
53+
54+
### Use of native role based menu permissions
55+
56+
Replace `role` option in menu configuration by `permission` (native EasyAdmin implementation). Empty menu folders are not pruned nor re-indexed with EasyAdmin implementation.
57+
58+
__BEFORE__
59+
60+
```yaml
61+
easy_admin:
62+
design:
63+
menu:
64+
- { label: Dashboard, route: admin_dashboard, icon: home, default: true }
65+
- { label: Challenges, entity: Challenge, icon: running, role: ROLE_CHALLENGE_LIST }
66+
```
67+
68+
__AFTER__
69+
70+
```yaml
71+
easy_admin:
72+
design:
73+
menu:
74+
- { label: Dashboard, route: admin_dashboard, icon: home, default: true }
75+
- { label: Challenges, entity: Challenge, icon: running, permission: ROLE_CHALLENGE_LIST }
76+
```
77+
78+
Note that `prune_menu_items` Twig function and `MenuHelper` service have been removed too.
79+
80+
381
## v2.1.0
482

583
List filters form have been improved, with minor BC breaks :

composer.json

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "alterphp/easyadmin-extension-bundle",
33
"type": "symfony-bundle",
4-
"description": "This bundle provides some extensions to javiereguiluz/easyadmin-bundle",
4+
"description": "This bundle provides some extensions to easycorp/easyadmin-bundle",
55
"keywords": ["backend", "admin", "generator"],
66
"homepage": "https://github.com/alterphp/EasyAdminExtensionBundle",
77
"license": "MIT",
@@ -15,44 +15,49 @@
1515
"php": "^7.1.3",
1616
"doctrine/collections": "^1.5",
1717
"doctrine/common": "^2.8",
18-
"doctrine/doctrine-bundle": "^1.8",
18+
"doctrine/doctrine-bundle": "^1.8|^2.0",
1919
"doctrine/orm": "^2.6",
20-
"easycorp/easyadmin-bundle": "^2.0,<2.2.0",
20+
"easycorp/easyadmin-bundle": "^2.2.2",
2121
"league/uri-manipulations": "^1.3",
2222
"league/uri-schemes": "^1.2",
23-
"symfony/config": "^4.1",
24-
"symfony/dependency-injection": "^4.1",
25-
"symfony/event-dispatcher": "^4.1",
26-
"symfony/form": "^4.1",
27-
"symfony/framework-bundle": "^4.1",
28-
"symfony/http-foundation": "^4.1",
29-
"symfony/http-kernel": "^4.1",
30-
"symfony/property-access": "^4.1",
31-
"symfony/validator": "^4.1",
32-
"twig/twig": "^2.4"
23+
"symfony/config": "^4.2|^5.0",
24+
"symfony/dependency-injection": "^4.2|^5.0",
25+
"symfony/event-dispatcher": "^4.2|^5.0",
26+
"symfony/form": "^4.2|^5.0",
27+
"symfony/framework-bundle": "^4.2|^5.0",
28+
"symfony/http-foundation": "^4.2|^5.0",
29+
"symfony/http-kernel": "^4.2|^5.0",
30+
"symfony/property-access": "^4.2|^5.0",
31+
"symfony/validator": "^4.2|^5.0",
32+
"twig/twig": "^2.11.3|^3.0"
3333
},
3434
"require-dev": {
35+
"doctrine/data-fixtures": "^1.3",
3536
"doctrine/doctrine-fixtures-bundle": "^3.0",
3637
"friendsofphp/php-cs-fixer": "^2.11",
3738
"php-coveralls/php-coveralls": "^2.0",
38-
"phpstan/phpstan": "^0.9.2",
39-
"phpunit/phpunit": "~5",
39+
"phpstan/phpstan": "dev-master",
4040
"psr/log": "~1.0",
41-
"symfony/browser-kit": "^4.1",
42-
"symfony/console": "^4.1",
43-
"symfony/css-selector": "^4.1",
44-
"symfony/dom-crawler": "^4.1",
45-
"symfony/phpunit-bridge": "^4.1",
46-
"symfony/polyfill": "^1.7",
47-
"symfony/security-bundle": "^4.1",
48-
"symfony/templating": "^4.1",
49-
"symfony/thanks": "^1.0",
50-
"symfony/twig-bundle": "^4.1",
51-
"symfony/var-dumper": "^4.1"
41+
"symfony/browser-kit": "^4.2|^5.0",
42+
"symfony/console": "^4.2|^5.0",
43+
"symfony/css-selector": "^4.2|^5.0",
44+
"symfony/dom-crawler": "^4.2|^5.0",
45+
"symfony/phpunit-bridge": "^4.3.5|^5.0",
46+
"symfony/polyfill-mbstring": "^1.7",
47+
"symfony/security-bundle": "^4.2|^5.0",
48+
"symfony/templating": "^4.2|^5.0",
49+
"symfony/thanks": "^1.2.4",
50+
"symfony/twig-bundle": "^4.2|^5.0",
51+
"symfony/var-dumper": "^4.2|^5.0",
52+
"symfony/yaml": "^4.2|^5.0"
53+
},
54+
"conflict": {
55+
"easycorp/easyadmin-bundle": "<2.2.2"
5256
},
5357
"config": {
5458
"sort-packages": true,
5559
"platform": {
60+
"php": "7.1.3",
5661
"ext-intl": "1.0"
5762
}
5863
},
@@ -68,7 +73,7 @@
6873
},
6974
"extra": {
7075
"branch-alias": {
71-
"dev-master": "2.1.x-dev"
76+
"dev-master": "3.0.x-dev"
7277
}
7378
}
7479
}

docker-compose.yml.dist

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,8 @@ services:
77
volumes:
88
- ./:/app
99
entrypoint:
10-
- php
11-
- /app/vendor/bin/simple-phpunit
10+
- 'php'
11+
- '/app/vendor/bin/simple-phpunit'
12+
- '-c'
13+
- '/app/phpunit.xml.dist'
1214

13-
php-cs-fixer:
14-
image: ekreative/php-cs-fixer
15-
volumes:
16-
- ./:/app
17-
entrypoint:
18-
- /usr/local/bin/php-cs-fixer
19-
- fix
20-
- /app

docker/phpunit/Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
FROM phpunit/phpunit:latest
1+
FROM php:7.1
22

3-
RUN apk --no-cache add php7-iconv
4-
RUN apk --no-cache add php7-simplexml
3+
RUN apt-get update && \
4+
apt-get install -y --no-install-recommends git zip
5+
6+
RUN curl --silent --show-error https://getcomposer.org/installer | php
7+
8+
# RUN apk --no-cache add php7-iconv
9+
# RUN apk --no-cache add php7-simplexml

0 commit comments

Comments
 (0)