Skip to content

Commit 72b1600

Browse files
committed
Merge pull request #22 from Fooriva/3.1
Add customizable twig environment in twigColumn
2 parents 6418e05 + d5634a3 commit 72b1600

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,25 @@ class TwigColumn extends EvoluGridColumn implements EvoluColumnKeyInterface, Evo
8080
* @param bool $sortable True if the column is sortable, false otherwise.
8181
* @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.
8282
* @param ConditionInterface $displayCondition
83-
* @internal param string $key Get the key to map to in the datagrid. Only used for sort order.
83+
* @param Twig_Environment $twigEnvironment
8484
*/
85-
public function __construct($title, $twig, $sortKey = null, $sortable = false, $width = null, $displayCondition = null) {
85+
public function __construct($title, $twig, $sortKey = null, $sortable = false, $width = null, $displayCondition = null, Twig_Environment $twigEnvironment = null) {
8686
$this->title = $title;
8787
$this->twig = $twig;
8888
$this->sortKey = $sortKey;
8989
$this->sortable = $sortable;
9090
$this->width = $width;
9191
$this->displayCondition = $displayCondition;
92-
92+
9393
self::$COLUMN_NUMBER++;
9494
$this->columnNumber = self::$COLUMN_NUMBER;
95-
96-
$loader = new \Twig_Loader_String();
97-
$this->twigEnvironment = new \Twig_Environment($loader);
95+
96+
if (null === $twigEnvironment) {
97+
$loader = new \Twig_Loader_String();
98+
$this->twigEnvironment = new \Twig_Environment($loader);
99+
} else {
100+
$this->twigEnvironment = $twigEnvironment;
101+
}
98102
}
99103

100104
/**

0 commit comments

Comments
 (0)