Skip to content

Commit

Permalink
allow symfony/http-foundation and symfony/validator 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher committed Aug 30, 2020
1 parent 63de836 commit 2f9acac
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"symfony/expression-language": "^4.4 || ^5.1",
"symfony/form": "^4.4",
"symfony/framework-bundle": "^4.4",
"symfony/http-foundation": "^4.4",
"symfony/http-foundation": "^4.4 || ^5.1",
"symfony/http-kernel": "^4.4",
"symfony/options-resolver": "^4.4 || ^5.1",
"symfony/property-access": "^4.4 || ^5.1",
Expand All @@ -57,7 +57,7 @@
"symfony/translation": "^4.4",
"symfony/twig-bridge": "^4.4",
"symfony/twig-bundle": "^4.4",
"symfony/validator": "^4.4",
"symfony/validator": "^4.4 || ^5.1",
"twig/string-extra": "^3.0",
"twig/twig": "^2.12.1 || ^3.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Action/RetrieveAutocompleteItemsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function __invoke(Request $request): JsonResponse
}

$datagrid->setValue('_per_page', null, $itemsPerPage);
$datagrid->setValue('_page', null, $request->query->get($reqParamPageNumber, 1));
$datagrid->setValue('_page', null, $request->query->get($reqParamPageNumber, '1'));
$datagrid->buildPager();

$pager = $datagrid->getPager();
Expand Down
11 changes: 10 additions & 1 deletion src/Admin/AbstractAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\PropertyAccess\PropertyPath;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface as RoutingUrlGeneratorInterface;
Expand Down Expand Up @@ -812,7 +814,14 @@ public function getFilterParameters()

// build the values array
if ($this->hasRequest()) {
$filters = $this->request->query->get('filter', []);
/** @var InputBag|ParameterBag $bag */
$bag = $this->request->query;
if ($bag instanceof InputBag) {
// symfony 5.1+
$filters = $bag->all('filter');
} else {
$filters = $bag->get('filter', []);
}
if (isset($filters['_page'])) {
$filters['_page'] = (int) $filters['_page'];
}
Expand Down
9 changes: 8 additions & 1 deletion src/Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormRenderer;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -429,7 +430,13 @@ public function batchAction()
$forwardedRequest->request->replace(array_merge($forwardedRequest->request->all(), $data));
} else {
$action = $forwardedRequest->request->get('action');
$idx = $request->request->get('idx', []);
$bag = $request->request;
if ($bag instanceof InputBag) {
// symfony 5.1+
$idx = $bag->all('idx');
} else {
$idx = $bag->get('idx', []);
}
$allElements = $forwardedRequest->request->getBoolean('all_elements');

$forwardedRequest->request->set('idx', $idx);
Expand Down
3 changes: 3 additions & 0 deletions tests/Admin/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,7 @@ public function testGetNewInstanceForChildAdminWithParentValue(): void

$postAdmin = $this->getMockBuilder(PostAdmin::class)->disableOriginalConstructor()->getMock();
$postAdmin->method('getObject')->willReturn($post);
$postAdmin->method('getIdParameter')->willReturn('parent_id');

$formBuilder = $this->createStub(FormBuilderInterface::class);
$formBuilder->method('getForm')->willReturn(null);
Expand Down Expand Up @@ -1629,6 +1630,7 @@ public function testGetNewInstanceForChildAdminWithCollectionParentValue(): void

$postAdmin = $this->getMockBuilder(PostAdmin::class)->disableOriginalConstructor()->getMock();
$postAdmin->method('getObject')->willReturn($post);
$postAdmin->method('getIdParameter')->willReturn('parent_id');

$formBuilder = $this->createStub(FormBuilderInterface::class);
$formBuilder->method('getForm')->willReturn(null);
Expand Down Expand Up @@ -1666,6 +1668,7 @@ public function testGetNewInstanceForEmbededAdminWithParentValue(): void

$postAdmin = $this->getMockBuilder(PostAdmin::class)->disableOriginalConstructor()->getMock();
$postAdmin->method('getObject')->willReturn($post);
$postAdmin->method('getIdParameter')->willReturn('parent_id');

$formBuilder = $this->createStub(FormBuilderInterface::class);
$formBuilder->method('getForm')->willReturn(null);
Expand Down
1 change: 1 addition & 0 deletions tests/Controller/CRUDControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@ public function testDeleteActionChildDeprecation(): void
$object2 = new \stdClass();

$admin = $this->createMock(PostAdmin::class);
$admin->method('getIdParameter')->willReturn('parent_id');

$admin->expects($this->once())
->method('getObject')
Expand Down

0 comments on commit 2f9acac

Please sign in to comment.