Skip to content

Commit

Permalink
Merge pull request #7 from rabauss/feature/twig3
Browse files Browse the repository at this point in the history
Fix compatibility with twig version 3
  • Loading branch information
bresam authored Mar 4, 2022
2 parents 5789543 + e6784f8 commit 1bb72e7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
11 changes: 7 additions & 4 deletions Tests/Twig/AbstractExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
namespace Ivory\GoogleMapBundle\Tests\Twig;

use PHPUnit\Framework\TestCase;
use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\Loader\FilesystemLoader;

/**
* @author GeLo <[email protected]>
*/
abstract class AbstractExtensionTest extends TestCase
{
/**
* @var \Twig_Environment
* @var Environment
*/
private $twig;

Expand All @@ -28,17 +31,17 @@ abstract class AbstractExtensionTest extends TestCase
*/
protected function setUp()
{
$this->twig = new \Twig_Environment(new \Twig_Loader_Filesystem([]));
$this->twig = new Environment(new FilesystemLoader([]));
$this->twig->addExtension($this->createExtension());
}

/**
* @return \Twig_Extension
* @return AbstractExtension
*/
abstract protected function createExtension();

/**
* @return \Twig_Environment
* @return Environment
*/
protected function getTwig()
{
Expand Down
6 changes: 4 additions & 2 deletions Twig/ApiExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
namespace Ivory\GoogleMapBundle\Twig;

use Ivory\GoogleMap\Helper\ApiHelper;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

/**
* @author GeLo <[email protected]>
*/
class ApiExtension extends \Twig_Extension
class ApiExtension extends AbstractExtension
{
/**
* @var ApiHelper
Expand All @@ -39,7 +41,7 @@ public function getFunctions()
$functions = [];

foreach ($this->getMapping() as $name => $method) {
$functions[] = new \Twig_SimpleFunction($name, [$this, $method], ['is_safe' => ['html']]);
$functions[] = new TwigFunction($name, [$this, $method], ['is_safe' => ['html']]);
}

return $functions;
Expand Down
6 changes: 4 additions & 2 deletions Twig/MapExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

use Ivory\GoogleMap\Helper\MapHelper;
use Ivory\GoogleMap\Map;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

/**
* @author GeLo <[email protected]>
*/
class MapExtension extends \Twig_Extension
class MapExtension extends AbstractExtension
{
/**
* @var MapHelper
Expand All @@ -40,7 +42,7 @@ public function getFunctions()
$functions = [];

foreach ($this->getMapping() as $name => $method) {
$functions[] = new \Twig_SimpleFunction($name, [$this, $method], ['is_safe' => ['html']]);
$functions[] = new TwigFunction($name, [$this, $method], ['is_safe' => ['html']]);
}

return $functions;
Expand Down
6 changes: 4 additions & 2 deletions Twig/PlaceAutocompleteExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

use Ivory\GoogleMap\Helper\PlaceAutocompleteHelper;
use Ivory\GoogleMap\Place\Autocomplete;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

/**
* @author GeLo <[email protected]>
*/
class PlaceAutocompleteExtension extends \Twig_Extension
class PlaceAutocompleteExtension extends AbstractExtension
{
/**
* @var PlaceAutocompleteHelper
Expand All @@ -40,7 +42,7 @@ public function getFunctions()
$functions = [];

foreach ($this->getMapping() as $name => $method) {
$functions[] = new \Twig_SimpleFunction($name, [$this, $method], ['is_safe' => ['html']]);
$functions[] = new TwigFunction($name, [$this, $method], ['is_safe' => ['html']]);
}

return $functions;
Expand Down
6 changes: 4 additions & 2 deletions Twig/StaticMapExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

use Ivory\GoogleMap\Helper\StaticMapHelper;
use Ivory\GoogleMap\Map;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

/**
* @author GeLo <[email protected]>
*/
class StaticMapExtension extends \Twig_Extension
class StaticMapExtension extends AbstractExtension
{
/**
* @var StaticMapHelper
Expand All @@ -40,7 +42,7 @@ public function getFunctions()
$functions = [];

foreach ($this->getMapping() as $name => $method) {
$functions[] = new \Twig_SimpleFunction($name, [$this, $method], ['is_safe' => ['html']]);
$functions[] = new TwigFunction($name, [$this, $method], ['is_safe' => ['html']]);
}

return $functions;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"symfony/phpunit-bridge": "^2.7 || ^3.0 || ^4.0",
"symfony/templating": "^2.7 || ^3.0 || ^4.0",
"symfony/yaml": "^2.7 || ^3.0 || ^4.0",
"twig/twig": "^1.18"
"twig/twig": "^2.7 || ^3.0"
},
"autoload": {
"psr-4": { "Ivory\\GoogleMapBundle\\": "" }
Expand Down

0 comments on commit 1bb72e7

Please sign in to comment.