Skip to content

Commit cf25d57

Browse files
committed
Fix compatibility issues with Symfony 5.x
1 parent b6467b1 commit cf25d57

18 files changed

+50
-57
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
99
- Drop Symfony 3.x compatibility
1010
- Drop PHP <7.2 compatibility
1111

12+
### Deprecated
13+
- DataTablesTrait should be dropped in favor of injection
14+
1215
## [0.3.1] - 2019-08-09
1316
### Added
1417
- Update the url used for ajax request on each init. (#75)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![SensioLabs Insight](https://img.shields.io/sensiolabs/i/05d79ba2-cba4-4201-a17a-2868c51f9c6c.svg)](https://insight.sensiolabs.com/projects/05d79ba2-cba4-4201-a17a-2868c51f9c6c)
1010

1111
This bundle provides convenient integration of the popular [DataTables](https://datatables.net/) jQuery library
12-
for realtime Ajax tables in your [Symfony](https://symfony.com/) 3.4+ or 4.1+ application.
12+
for realtime Ajax tables in your [Symfony](https://symfony.com/) 4.1+ or 5.0+ application.
1313

1414
Unlike other bundles providing similar functionality we decoupled the implementation of the DataTables logic
1515
completely from the source of the data. Therefore it is possible to implement your own custom adapters for

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"doctrine/orm": "^2.5",
3333
"friendsofphp/php-cs-fixer": "^2.7",
3434
"mongodb/mongodb": "^1.2",
35-
"phpunit/phpunit": "^7.1|^8.0",
35+
"phpunit/phpunit": "^7.1",
3636
"ruflin/elastica": "^6.0|^7.0",
3737
"symfony/browser-kit": "^4.1|^5.0",
3838
"symfony/css-selector": "^4.1|^5.0",

src/Adapter/Doctrine/Event/ORMAdapterQueryEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace Omines\DataTablesBundle\Adapter\Doctrine\Event;
1414

1515
use Doctrine\ORM\Query;
16-
use Symfony\Component\EventDispatcher\Event;
16+
use Symfony\Contracts\EventDispatcher\Event;
1717

1818
/**
1919
* @author Maxime Pinot <[email protected]>

src/Adapter/Doctrine/ORMAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ protected function getResults(AdapterQuery $query): \Traversable
190190

191191
$query = $builder->getQuery();
192192
$event = new ORMAdapterQueryEvent($query);
193-
$state->getDataTable()->getEventDispatcher()->dispatch(ORMAdapterEvents::PRE_QUERY, $event);
193+
$state->getDataTable()->getEventDispatcher()->dispatch($event, ORMAdapterEvents::PRE_QUERY);
194194

195195
foreach ($query->iterate([], $this->hydrationMode) as $result) {
196196
yield $entity = array_values($result)[0];

src/Column/TwigColumn.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use Omines\DataTablesBundle\Exception\MissingDependencyException;
1616
use Symfony\Component\OptionsResolver\OptionsResolver;
17-
use Twig_Environment;
17+
use Twig\Environment;
1818

1919
/**
2020
* TwigColumn.
@@ -23,13 +23,13 @@
2323
*/
2424
class TwigColumn extends AbstractColumn
2525
{
26-
/** @var Twig_Environment */
26+
/** @var Environment */
2727
private $twig;
2828

2929
/**
3030
* TwigColumn constructor.
3131
*/
32-
public function __construct(Twig_Environment $twig = null)
32+
public function __construct(Environment $twig = null)
3333
{
3434
if (null === ($this->twig = $twig)) {
3535
throw new MissingDependencyException('You must have TwigBundle installed to use ' . self::class);

src/Controller/DataTablesTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* @author Niels Keurentjes <[email protected]>
2323
*
2424
* @property ContainerInterface $container
25+
*
26+
* @deprecated inject the DataTableFactory in your controllers or actions instead
2527
*/
2628
trait DataTablesTrait
2729
{

tests/Fixtures/AppBundle/Controller/CustomQueryController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace Tests\Fixtures\AppBundle\Controller;
1414

15-
use Omines\DataTablesBundle\Controller\DataTablesTrait;
15+
use Omines\DataTablesBundle\DataTableFactory;
1616
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -25,11 +25,9 @@
2525
*/
2626
class CustomQueryController extends AbstractController
2727
{
28-
use DataTablesTrait;
29-
30-
public function tableAction(Request $request)
28+
public function tableAction(Request $request, DataTableFactory $dataTableFactory)
3129
{
32-
$datatable = $this->createDataTableFromType(CustomQueryTableType::class)
30+
$datatable = $dataTableFactory->createFromType(CustomQueryTableType::class)
3331
->setMethod(Request::METHOD_GET);
3432
if ($datatable->handleRequest($request)->isCallback()) {
3533
return $datatable->getResponse();

tests/Fixtures/AppBundle/Controller/GroupedController.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace Tests\Fixtures\AppBundle\Controller;
1414

15-
use Omines\DataTablesBundle\Controller\DataTablesTrait;
15+
use Omines\DataTablesBundle\DataTableFactory;
1616
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Tests\Fixtures\AppBundle\DataTable\Type\Grouped2TableType;
@@ -25,21 +25,19 @@
2525
*/
2626
class GroupedController extends AbstractController
2727
{
28-
use DataTablesTrait;
29-
30-
public function tableAction(Request $request)
28+
public function tableAction(Request $request, DataTableFactory $dataTableFactory)
3129
{
32-
$datatable = $this->createDataTableFromType(GroupedTableType::class)
30+
$datatable = $dataTableFactory->createFromType(GroupedTableType::class)
3331
->setName('companies')
3432
->setMethod(Request::METHOD_GET)
3533
;
3634

3735
return $datatable->handleRequest($request)->getResponse();
3836
}
3937

40-
public function table2Action(Request $request)
38+
public function table2Action(Request $request, DataTableFactory $dataTableFactory)
4139
{
42-
$datatable = $this->createDataTableFromType(Grouped2TableType::class)
40+
$datatable = $dataTableFactory->createFromType(Grouped2TableType::class)
4341
->setName('companies2')
4442
->setMethod(Request::METHOD_GET)
4543
;

tests/Fixtures/AppBundle/Controller/HomeController.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use Omines\DataTablesBundle\Adapter\ArrayAdapter;
1616
use Omines\DataTablesBundle\Column\TextColumn;
17-
use Omines\DataTablesBundle\Controller\DataTablesTrait;
17+
use Omines\DataTablesBundle\DataTableFactory;
1818
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1919
use Symfony\Component\HttpFoundation\Request;
2020

@@ -25,9 +25,7 @@
2525
*/
2626
class HomeController extends AbstractController
2727
{
28-
use DataTablesTrait;
29-
30-
public function showAction(Request $request)
28+
public function showAction(Request $request, DataTableFactory $dataTableFactory)
3129
{
3230
$datatable1 = $this->createDataTable();
3331
$datatable1

0 commit comments

Comments
 (0)