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

Commit bc25e94

Browse files
author
Victor Macko
committed
Updated to support Symfony 5.0 & Twig 3.0
1 parent 51cebfd commit bc25e94

File tree

7 files changed

+33
-33
lines changed

7 files changed

+33
-33
lines changed

Datatable/AbstractDatatable.php

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
2121
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
2222
use Symfony\Component\Translation\TranslatorInterface;
23-
use Twig_Environment;
23+
use Twig\Environment;
2424

2525
abstract class AbstractDatatable implements DatatableInterface
2626
{
@@ -62,7 +62,7 @@ abstract class AbstractDatatable implements DatatableInterface
6262
/**
6363
* The Twig Environment.
6464
*
65-
* @var Twig_Environment
65+
* @var Environment
6666
*/
6767
protected $twig;
6868

@@ -154,7 +154,7 @@ public function __construct(
154154
TranslatorInterface $translator,
155155
RouterInterface $router,
156156
EntityManagerInterface $em,
157-
Twig_Environment $twig
157+
Environment $twig
158158
) {
159159
$this->validateName();
160160

Datatable/Column/AbstractColumn.php

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Sg\DatatablesBundle\Datatable\OptionsTrait;
2020
use Symfony\Component\OptionsResolver\OptionsResolver;
2121
use Symfony\Component\Routing\RouterInterface;
22-
use Twig_Environment;
22+
use Twig\Environment;
2323

2424
abstract class AbstractColumn implements ColumnInterface
2525
{
@@ -915,7 +915,7 @@ public function getTwig()
915915
/**
916916
* @return $this
917917
*/
918-
public function setTwig(Twig_Environment $twig)
918+
public function setTwig(Environment $twig)
919919
{
920920
$this->twig = $twig;
921921

Datatable/Column/ColumnBuilder.php

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Exception;
1818
use Sg\DatatablesBundle\Datatable\Factory;
1919
use Symfony\Component\Routing\RouterInterface;
20-
use Twig_Environment;
20+
use Twig\Environment;
2121

2222
class ColumnBuilder
2323
{
@@ -88,7 +88,7 @@ class ColumnBuilder
8888
/**
8989
* @param string $datatableName
9090
*/
91-
public function __construct(ClassMetadata $metadata, Twig_Environment $twig, RouterInterface $router, $datatableName, EntityManagerInterface $em)
91+
public function __construct(ClassMetadata $metadata, Environment $twig, RouterInterface $router, $datatableName, EntityManagerInterface $em)
9292
{
9393
$this->metadata = $metadata;
9494
$this->twig = $twig;

Datatable/DatatableFactory.php

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1818
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
1919
use Symfony\Component\Translation\TranslatorInterface;
20-
use Twig_Environment;
20+
use Twig\Environment;
2121

2222
class DatatableFactory
2323
{
@@ -69,7 +69,7 @@ public function __construct(
6969
TranslatorInterface $translator,
7070
RouterInterface $router,
7171
EntityManagerInterface $em,
72-
Twig_Environment $twig
72+
Environment $twig
7373
) {
7474
$this->authorizationChecker = $authorizationChecker;
7575
$this->securityToken = $securityToken;

Tests/DatatableTest.php

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1818
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
1919
use Symfony\Component\Translation\TranslatorInterface;
20-
use Twig_Environment;
20+
use Twig\Environment;
2121

2222
/**
2323
* @internal
@@ -38,7 +38,7 @@ public function testCreate()
3838
/** @noinspection PhpUndefinedMethodInspection */
3939
$router = $this->createMock(RouterInterface::class);
4040
/** @noinspection PhpUndefinedMethodInspection */
41-
$twig = $this->createMock(Twig_Environment::class);
41+
$twig = $this->createMock(Environment::class);
4242

4343
/** @noinspection PhpUndefinedMethodInspection */
4444
$em = $this->getMockBuilder(EntityManager::class)

Twig/DatatableTwigExtension.php

100644100755
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
use Sg\DatatablesBundle\Datatable\Filter\FilterInterface;
1919
use Symfony\Component\PropertyAccess\PropertyAccess;
2020
use Symfony\Component\PropertyAccess\PropertyAccessor;
21-
use Twig_Environment;
22-
use Twig_Extension;
23-
use Twig_SimpleFilter;
24-
use Twig_SimpleFunction;
21+
use Twig\Environment;
22+
use Twig\Extension\AbstractExtension;
23+
use Twig\TwigFilter;
24+
use Twig\TwigFunction;
2525

26-
class DatatableTwigExtension extends Twig_Extension
26+
class DatatableTwigExtension extends AbstractExtension
2727
{
2828
/**
2929
* The PropertyAccessor.
@@ -55,27 +55,27 @@ public function getName()
5555
public function getFunctions()
5656
{
5757
return [
58-
new Twig_SimpleFunction(
58+
new TwigFunction(
5959
'sg_datatables_render',
6060
[$this, 'datatablesRender'],
6161
['is_safe' => ['html'], 'needs_environment' => true]
6262
),
63-
new Twig_SimpleFunction(
63+
new TwigFunction(
6464
'sg_datatables_render_html',
6565
[$this, 'datatablesRenderHtml'],
6666
['is_safe' => ['html'], 'needs_environment' => true]
6767
),
68-
new Twig_SimpleFunction(
68+
new TwigFunction(
6969
'sg_datatables_render_js',
7070
[$this, 'datatablesRenderJs'],
7171
['is_safe' => ['html'], 'needs_environment' => true]
7272
),
73-
new Twig_SimpleFunction(
73+
new TwigFunction(
7474
'sg_datatables_render_filter',
7575
[$this, 'datatablesRenderFilter'],
7676
['is_safe' => ['html'], 'needs_environment' => true]
7777
),
78-
new Twig_SimpleFunction(
78+
new TwigFunction(
7979
'sg_datatables_render_multiselect_actions',
8080
[$this, 'datatablesRenderMultiselectActions'],
8181
['is_safe' => ['html'], 'needs_environment' => true]
@@ -89,7 +89,7 @@ public function getFunctions()
8989
public function getFilters()
9090
{
9191
return [
92-
new Twig_SimpleFilter('sg_datatables_bool_var', [$this, 'boolVar']),
92+
new TwigFilter('sg_datatables_bool_var', [$this, 'boolVar']),
9393
];
9494
}
9595

@@ -102,7 +102,7 @@ public function getFilters()
102102
*
103103
* @return string
104104
*/
105-
public function datatablesRender(Twig_Environment $twig, DatatableInterface $datatable)
105+
public function datatablesRender(Environment $twig, DatatableInterface $datatable)
106106
{
107107
return $twig->render(
108108
'@SgDatatables/datatable/datatable.html.twig',
@@ -117,7 +117,7 @@ public function datatablesRender(Twig_Environment $twig, DatatableInterface $dat
117117
*
118118
* @return string
119119
*/
120-
public function datatablesRenderHtml(Twig_Environment $twig, DatatableInterface $datatable)
120+
public function datatablesRenderHtml(Environment $twig, DatatableInterface $datatable)
121121
{
122122
return $twig->render(
123123
'@SgDatatables/datatable/datatable_html.html.twig',
@@ -132,7 +132,7 @@ public function datatablesRenderHtml(Twig_Environment $twig, DatatableInterface
132132
*
133133
* @return string
134134
*/
135-
public function datatablesRenderJs(Twig_Environment $twig, DatatableInterface $datatable)
135+
public function datatablesRenderJs(Environment $twig, DatatableInterface $datatable)
136136
{
137137
return $twig->render(
138138
'@SgDatatables/datatable/datatable_js.html.twig',
@@ -149,7 +149,7 @@ public function datatablesRenderJs(Twig_Environment $twig, DatatableInterface $d
149149
*
150150
* @return string
151151
*/
152-
public function datatablesRenderFilter(Twig_Environment $twig, DatatableInterface $datatable, ColumnInterface $column, $position)
152+
public function datatablesRenderFilter(Environment $twig, DatatableInterface $datatable, ColumnInterface $column, $position)
153153
{
154154
/** @var FilterInterface $filter */
155155
$filter = $this->accessor->getValue($column, 'filter');
@@ -181,7 +181,7 @@ public function datatablesRenderFilter(Twig_Environment $twig, DatatableInterfac
181181
*
182182
* @return string
183183
*/
184-
public function datatablesRenderMultiselectActions(Twig_Environment $twig, ColumnInterface $multiselectColumn, $pipeline)
184+
public function datatablesRenderMultiselectActions(Environment $twig, ColumnInterface $multiselectColumn, $pipeline)
185185
{
186186
$parameters = [];
187187
$values = [];

composer.json

100644100755
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
"php": ">=7.1",
2222
"doctrine/orm": "^2.5",
2323
"friendsofsymfony/jsrouting-bundle": "^1.6|^2.0",
24-
"symfony/framework-bundle": "^3.4|^4.1",
25-
"symfony/options-resolver": "^3.4|^4.1",
26-
"symfony/property-access": "^3.4|^4.1",
27-
"symfony/security": "^3.4|^4.1",
28-
"symfony/translation": "^3.4|^4.1",
29-
"twig/twig": "^2.9"
24+
"symfony/framework-bundle": "^3.4|^4.1|^5.0",
25+
"symfony/options-resolver": "^3.4|^4.1|^5.0",
26+
"symfony/property-access": "^3.4|^4.1|^5.0",
27+
"symfony/security": "^3.4|^4.1|^5.0",
28+
"symfony/translation": "^3.4|^4.1|^5.0",
29+
"twig/twig": "^2.9|^3.0"
3030
},
3131
"require-dev": {
3232
"phpunit/phpunit": "5.7.*",

0 commit comments

Comments
 (0)