Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow symfony/http-foundation and symfony/validator 5.1 #6344

Merged
merged 2 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'));
jordisala1991 marked this conversation as resolved.
Show resolved Hide resolved
$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 */
jordisala1991 marked this conversation as resolved.
Show resolved Hide resolved
$bag = $this->request->query;
if ($bag instanceof InputBag) {
// symfony 5.1+
jordisala1991 marked this conversation as resolved.
Show resolved Hide resolved
$filters = $bag->all('filter');
} else {
$filters = $bag->get('filter', []);
}
if (isset($filters['_page'])) {
$filters['_page'] = (int) $filters['_page'];
}
Expand Down
11 changes: 10 additions & 1 deletion src/Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
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\ParameterBag;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -429,7 +431,14 @@ public function batchAction()
$forwardedRequest->request->replace(array_merge($forwardedRequest->request->all(), $data));
} else {
$action = $forwardedRequest->request->get('action');
$idx = $request->request->get('idx', []);
/** @var InputBag|ParameterBag $bag */
$bag = $request->request;
jordisala1991 marked this conversation as resolved.
Show resolved Hide resolved
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');
jordisala1991 marked this conversation as resolved.
Show resolved Hide resolved

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