From 7fc0913b4f8824d964d55e8eff2d55a9866885ed Mon Sep 17 00:00:00 2001 From: Florian Rey Date: Mon, 10 Sep 2018 13:09:49 +0200 Subject: [PATCH 1/2] Cleanup twig namespaces --- Twig/DumpyTwigFilter.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Twig/DumpyTwigFilter.php b/Twig/DumpyTwigFilter.php index 38b88eb..b582365 100755 --- a/Twig/DumpyTwigFilter.php +++ b/Twig/DumpyTwigFilter.php @@ -11,6 +11,8 @@ use Elao\ErrorNotifierBundle\Exception\InvokerException; use Symfony\Component\Yaml\Dumper as YamlDumper; +use Twig_Extension; +use Twig_SimpleFilter; /** * Extends Twig with @@ -36,7 +38,7 @@ * * @author Goutte */ -class DumpyTwigFilter extends \Twig_Extension +class DumpyTwigFilter extends Twig_Extension { /** @const INLINE : default value for the inline parameter of the YAML dumper aka the expanding-level */ const INLINE = 3; @@ -51,9 +53,9 @@ public function getFilters() $optionsForRaw = array('is_safe' => array('all')); // allows raw dumping (otherwise
 is encoded)
 
         return array(
-            'pre'   => new \Twig_SimpleFilter('pre', array($this, 'pre'), $optionsForRaw),
-            'dump'  => new \Twig_SimpleFilter('dump', array($this, 'preDump'), $optionsForRaw),
-            'dumpy' => new \Twig_SimpleFilter('dumpy', array($this, 'preYamlDump'), $optionsForRaw),
+            'pre'   => new Twig_SimpleFilter('pre', array($this, 'pre'), $optionsForRaw),
+            'dump'  => new Twig_SimpleFilter('dump', array($this, 'preDump'), $optionsForRaw),
+            'dumpy' => new Twig_SimpleFilter('dumpy', array($this, 'preYamlDump'), $optionsForRaw),
         );
     }
 

From 032e92e8440f1b8103b83df0ded7672ae4129374 Mon Sep 17 00:00:00 2001
From: Florian Rey 
Date: Mon, 10 Sep 2018 13:10:11 +0200
Subject: [PATCH 2/2] Switch from symfony templating to twig service

---
 Listener/Notifier.php         | 20 ++++++++++----------
 Resources/config/services.xml |  2 +-
 composer.json                 |  1 +
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Listener/Notifier.php b/Listener/Notifier.php
index d116480..2f18a2d 100644
--- a/Listener/Notifier.php
+++ b/Listener/Notifier.php
@@ -21,7 +21,7 @@
 use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
 use Symfony\Component\HttpKernel\Exception\HttpException;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
-use Symfony\Component\Templating\EngineInterface;
+use Twig_Environment;
 
 /**
  * Notifier
@@ -34,9 +34,9 @@ class Notifier
     private $mailer;
 
     /**
-     * @var EngineInterface
+     * @var Twig_Environment
      */
-    private $templating;
+    private $twig;
 
     /**
      * @var string
@@ -66,15 +66,15 @@ class Notifier
     /**
      * The constructor
      *
-     * @param Swift_Mailer    $mailer     mailer
-     * @param EngineInterface $templating templating
-     * @param string          $cacheDir   cacheDir
-     * @param array           $config     configure array
+     * @param Swift_Mailer     $mailer     mailer
+     * @param Twig_Environment $twig       twig
+     * @param string           $cacheDir   cacheDir
+     * @param array            $config     configure array
      */
-    public function __construct(Swift_Mailer $mailer, EngineInterface $templating, $cacheDir, $config)
+    public function __construct(Swift_Mailer $mailer, Twig_Environment $twig, $cacheDir, $config)
     {
         $this->mailer                = $mailer;
-        $this->templating            = $templating;
+        $this->twig                  = $twig;
         $this->from                  = $config['from'];
         $this->to                    = $config['to'];
         $this->handle404             = $config['handle404'];
@@ -330,7 +330,7 @@ public function createMailAndSend($exception, Request $request = null, $context
             return;
         }
 
-        $body = $this->templating->render('ElaoErrorNotifierBundle::mail.html.twig', array(
+        $body = $this->twig->render('ElaoErrorNotifierBundle::mail.html.twig', array(
             'exception'       => $exception,
             'request'         => $request ? $this->filterRequest($request): null,
             'status_code'     => $exception->getCode(),
diff --git a/Resources/config/services.xml b/Resources/config/services.xml
index 3e2ffbe..b5bacde 100755
--- a/Resources/config/services.xml
+++ b/Resources/config/services.xml
@@ -15,7 +15,7 @@
             
             
             
-            
+            
             %kernel.cache_dir%
             %elao.error_notifier.config%
         
diff --git a/composer.json b/composer.json
index 93bd4af..37930fc 100644
--- a/composer.json
+++ b/composer.json
@@ -21,6 +21,7 @@
         "php":                      ">=5.3.2",
         "symfony/framework-bundle": "~2.3|~3.0",
         "symfony/console":          "~2.3|~3.0",
+        "symfony/twig-bundle":      "~2.3|~3.0",
         "swiftmailer/swiftmailer":  "~5.0|~6.0"
     },