Skip to content

Commit

Permalink
replaced deprecated global Twig classes with namespaced classes (#12)
Browse files Browse the repository at this point in the history
* replaced deprecated global Twig classes with namespaced classes

* updated minimum twig version to be compatible with namespaced classes
  • Loading branch information
nutama authored and yannickl88 committed Mar 25, 2019
1 parent 31dfe75 commit 682d856
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"phpunit/phpunit": "^4.8.35|^6.0",
"symfony/twig-bundle": "^3.3|^4.0",
"symfony/yaml": "^3.3|^4.0",
"twig/twig": "^1.23.1|^2.0"
"twig/twig": "^1.38.1|^2.7.2"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
8 changes: 5 additions & 3 deletions src/Twig/FeaturesExtension.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php
namespace Yannickl88\FeaturesBundle\Twig;

use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use Yannickl88\FeaturesBundle\Feature\FeatureContainerInterface;

/**
* Twig extention for feature support in twig templates.
* Twig extension for feature support in twig templates.
*/
class FeaturesExtension extends \Twig_Extension
class FeaturesExtension extends AbstractExtension
{
/**
* @var FeatureContainerInterface
Expand All @@ -27,7 +29,7 @@ public function __construct(FeatureContainerInterface $container)
public function getFunctions()
{
return [
new \Twig_SimpleFunction('feature', function ($tag) {
new TwigFunction('feature', function ($tag) {
return $this->container->get($tag)->isActive();
}),
];
Expand Down
3 changes: 2 additions & 1 deletion test/Twig/FeaturesExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Yannickl88\FeaturesBundle\Twig;

use PHPUnit\Framework\TestCase;
use Twig\TwigFunction;
use Yannickl88\FeaturesBundle\Feature\Feature;
use Yannickl88\FeaturesBundle\Feature\FeatureContainerInterface;

Expand All @@ -26,7 +27,7 @@ protected function setUp()

public function testGetFunctions()
{
/* @var $functions \Twig_SimpleFunction[] */
/* @var $functions TwigFunction[] */
$functions = $this->features_extension->getFunctions();
$feature = $this->prophesize(Feature::class);

Expand Down

0 comments on commit 682d856

Please sign in to comment.