Skip to content

Commit

Permalink
Merge pull request #66 from sadikoff/master
Browse files Browse the repository at this point in the history
Make Twig dependency optional for use in API's
  • Loading branch information
laupiFrpar authored Sep 9, 2020
2 parents 141766c + 0ead0c5 commit 02d8950
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
5 changes: 5 additions & 0 deletions DependencyInjection/LopiPusherExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Twig\Extension\AbstractExtension;

/**
* LopiPusherExtension
Expand All @@ -34,6 +35,10 @@ public function load(array $configs, ContainerBuilder $container)

$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');

if (class_exists(AbstractExtension::class)) {
$loader->load('twig.xml');
}
}

/**
Expand Down
5 changes: 0 additions & 5 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@
<argument>%lopi_pusher.config%</argument>
</service>

<service id="lopi_pusher.twig_extension" class="Lopi\Bundle\PusherBundle\Twig\PusherExtension" public="false">
<argument type="service" id="lopi_pusher.pusher"></argument>
<tag name="twig.extension" />
</service>

</services>
</container>
15 changes: 15 additions & 0 deletions Resources/config/twig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>

<service id="lopi_pusher.twig_extension" class="Lopi\Bundle\PusherBundle\Twig\PusherExtension" public="false">
<argument type="service" id="lopi_pusher.pusher"/>
<tag name="twig.extension" />
</service>

</services>
</container>
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@
},
"require": {
"php": ">=7.2",
"pusher/pusher-php-server": "^4.0",
"twig/twig": "~2.7|~3.0"
"pusher/pusher-php-server": "^4.0"
},
"require-dev": {
"symfony/config": "~3.4",
"symfony/dependency-injection": "~3.4",
"symfony/http-kernel": "~3.4",
"twig/twig": "~2.7|~3.0",
"phpunit/phpunit": "7.*"
},
"autoload": {
"psr-4": {
"Lopi\\Bundle\\PusherBundle\\": ""
}
},
"conflict": {
"twig/twig": "<2.7"
}
}

0 comments on commit 02d8950

Please sign in to comment.