Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 7762593

Browse files
authored
Merge pull request #982 from webstacknl/develop
Support PHP 8 and Symfony 6
2 parents a9f18ef + a8b0fcb commit 7762593

File tree

5 files changed

+28
-342
lines changed

5 files changed

+28
-342
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Version 1.3
2+
3+
* Dropped support for PHP 7.1
4+
* Dropped support for Symfony 3.4 and <=4.3
5+
* Support for PHP 8
6+
* Support for Symfony 6
7+
18
# Version 1.1.1
29

310
* Bugfix: DateRangeFilter overwrites other filter (#803)

Command/CreateDatatableCommand.php

-213
This file was deleted.

Controller/DatatableController.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use DateTime;
1515
use Doctrine\DBAL\Types\Types;
16+
use Doctrine\ORM\EntityManagerInterface;
1617
use Exception;
1718
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1819
use Symfony\Component\HttpFoundation\Request;
@@ -37,7 +38,7 @@ class DatatableController extends AbstractController
3738
*
3839
* @return Response
3940
*/
40-
public function editAction(Request $request)
41+
public function editAction(Request $request, EntityManagerInterface $entityManager): Response
4142
{
4243
if ($request->isXmlHttpRequest()) {
4344
// x-editable sends some default parameters
@@ -57,7 +58,7 @@ public function editAction(Request $request)
5758
}
5859

5960
// get an object by its primary key
60-
$entity = $this->getEntityByPk($entityClassName, $pk);
61+
$entity = $this->getEntityByPk($entityClassName, $pk, $entityManager);
6162

6263
/** @var PropertyAccessor $accessor */
6364
/** @noinspection PhpUndefinedMethodInspection */
@@ -73,9 +74,8 @@ public function editAction(Request $request)
7374
null !== $path ? $accessor->setValue($entity, $path, $value) : $accessor->setValue($entity, $field, $value);
7475

7576
// save all
76-
$em = $this->getDoctrine()->getManager();
77-
$em->persist($entity);
78-
$em->flush();
77+
$entityManager->persist($entity);
78+
$entityManager->flush();
7979

8080
return new Response('Success', 200);
8181
}
@@ -92,11 +92,9 @@ public function editAction(Request $request)
9292
*
9393
* @param string $entityClassName
9494
*/
95-
private function getEntityByPk($entityClassName, $pk): object
95+
private function getEntityByPk($entityClassName, $pk, EntityManagerInterface $entityManager): object
9696
{
97-
$em = $this->getDoctrine()->getManager();
98-
99-
$entity = $em->getRepository($entityClassName)->find($pk);
97+
$entity = $entityManager->getRepository($entityClassName)->find($pk);
10098
if (! $entity) {
10199
throw $this->createNotFoundException('DatatableController::getEntityByPk(): The entity does not exist.');
102100
}

Generator/DatatableGenerator.php

-106
This file was deleted.

0 commit comments

Comments
 (0)