Skip to content

Commit 8bb1c8a

Browse files
committed
✨ Road to PHP 8
1 parent 32a5a8c commit 8bb1c8a

File tree

4 files changed

+80
-20
lines changed

4 files changed

+80
-20
lines changed

.gitignore

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
*~
2-
vendor/*
3-
.*~
4-
.buildpath
5-
.project
6-
.settings
1+
mouf/
2+
vendor/
3+
composer.lock

composer.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
"MIT"
2222
],
2323
"require" : {
24-
"php" : ">=7.0",
25-
"mouf/javascript.jquery.jquery" : ">=1.11",
24+
"php" : "^8.0",
25+
"mouf/javascript.jquery.jquery" : "^2.1",
2626
"mouf/database.querywriter" : "~4.0",
2727
"mouf/mvc.splash-common" : "~10.0",
2828
"mouf/utils.common.sortable-interface" : "~1.0",
2929
"mouf/html.utils.weblibrarymanager" : ">=2.0, <4.0",
3030
"mouf/utils.common.paginable-interface" : "~1.0",
3131
"mouf/utils.common.conditioninterface" : "2.*",
32-
"twig/twig" : "1.*@stable",
33-
"mouf/javascript.historyjs" : "~1.8",
32+
"twig/twig" : "^2",
33+
"mouf/javascript.historyjs" : "^1.8",
3434
"mouf/html.htmlelement" : "^2.0",
3535
"mouf/utils.common.formatters" : "~3.0",
3636
"mouf/utils.value.common-value" : "~1.0",
@@ -45,6 +45,7 @@
4545
}
4646
},
4747
"minimum-stability" : "dev",
48+
"prefer-stable" : true,
4849
"extra" : {
4950
"mouf" : {
5051
"install" : [{
@@ -73,5 +74,11 @@
7374
"src/EvolugridAdmin.php"
7475
]
7576
}
77+
},
78+
"config": {
79+
"allow-plugins": {
80+
"mouf/mouf-installer": true,
81+
"mouf/html.utils.weblibrarymanager.component-installer": true
82+
}
7683
}
7784
}

src/Mouf/Html/Widgets/EvoluGrid/TwigColumn.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
namespace Mouf\Html\Widgets\EvoluGrid;
44

55
use Mouf\Html\Widgets\EvoluGrid\Utils\ObjectToArrayCaster;
6+
use Mouf\Html\Widgets\EvoluGrid\Utils\TwigStringLoader;
67
use Mouf\Utils\Common\ConditionInterface\ConditionInterface;
78
use Mouf\Utils\Value\ValueInterface;
89
use Mouf\Utils\Value\ValueUtils;
9-
use Twig_Environment;
10+
use Twig\Environment;
1011

1112
/**
1213
* A column of an EvoluGrid that renders a key of the resultset.
13-
*
14+
*
1415
* @author David Negrier
1516
*/
1617
class TwigColumn extends EvoluGridColumn implements EvoluColumnInterface
@@ -28,28 +29,28 @@ class TwigColumn extends EvoluGridColumn implements EvoluColumnInterface
2829

2930
/**
3031
* The twig code to render the column.
31-
*
32+
*
3233
* @var string
3334
*/
3435
private $twig;
3536

3637
/**
3738
* True if the column is sortable, false otherwise.
38-
*
39+
*
3940
* @var bool
4041
*/
4142
private $sortable;
4243

4344
/**
4445
* Get the key to sort upon.
45-
*
46+
*
4647
* @var string
4748
*/
4849
private $sortKey;
4950

5051
/**
5152
* The width of the column.
52-
*
53+
*
5354
* @var int|string
5455
*/
5556
private $width;
@@ -82,9 +83,9 @@ class TwigColumn extends EvoluGridColumn implements EvoluColumnInterface
8283
* @param bool $sortable True if the column is sortable, false otherwise.
8384
* @param int|string $width Returns the width of the column. Just like the CSS width property, you can express it in %, px, em, etc... This is optional. Leave empty to let the browser decide.
8485
* @param ConditionInterface $displayCondition
85-
* @param Twig_Environment $twigEnvironment
86+
* @param Environment $twigEnvironment
8687
*/
87-
public function __construct($title, $twig, $sortKey = null, $sortable = false, $width = null, $displayCondition = null, Twig_Environment $twigEnvironment = null)
88+
public function __construct($title, $twig, $sortKey = null, $sortable = false, $width = null, $displayCondition = null, Environment $twigEnvironment = null)
8889
{
8990
$this->title = $title;
9091
$this->twig = $twig;
@@ -97,8 +98,8 @@ public function __construct($title, $twig, $sortKey = null, $sortable = false, $
9798
$this->columnNumber = self::$COLUMN_NUMBER;
9899

99100
if (null === $twigEnvironment) {
100-
$loader = new \Twig_Loader_String();
101-
$this->twigEnvironment = new \Twig_Environment($loader);
101+
$loader = new TwigStringLoader();
102+
$this->twigEnvironment = new Environment($loader);
102103
} else {
103104
$this->twigEnvironment = $twigEnvironment;
104105
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Mouf\Html\Widgets\EvoluGrid\Utils;
4+
5+
use Twig\Loader\LoaderInterface;
6+
use Twig\Source;
7+
8+
/**
9+
* This loader completely bypasses the loader mechanism, by directly passing the key as a template.
10+
* Useful in our very case.
11+
*
12+
* This is a reimplementation of Twig's String loader that has been deprecated.
13+
* We enable it back in our case because there won't be a million of different cache keys.
14+
* And yes, we know what we are doing :)
15+
*/
16+
class TwigStringLoader implements LoaderInterface
17+
{
18+
/**
19+
* {@inheritdoc}
20+
*/
21+
public function getSource($name)
22+
{
23+
return $name;
24+
}
25+
/**
26+
* {@inheritdoc}
27+
*/
28+
public function getCacheKey($name)
29+
{
30+
return $name;
31+
}
32+
/**
33+
* {@inheritdoc}
34+
*/
35+
public function isFresh($name, $time)
36+
{
37+
return true;
38+
}
39+
40+
/**
41+
* {@inheritdoc}
42+
*/
43+
public function getSourceContext($name)
44+
{
45+
return new Source($name, $name);
46+
}
47+
48+
/**
49+
* {@inheritdoc}
50+
*/
51+
public function exists($name)
52+
{
53+
return true;
54+
}
55+
}

0 commit comments

Comments
 (0)