]> Raphaël G. Git Repositories - packbundle/commitdiff
Add base64 extensions in twig
authorRaphaël Gertz <git@rapsys.eu>
Sun, 25 Feb 2018 04:58:43 +0000 (05:58 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Sun, 25 Feb 2018 04:58:43 +0000 (05:58 +0100)
Resources/config/services.yml
Twig/Base64Extension.php [new file with mode: 0644]

index dc64b83e88593eacd4f65e91dc1343b8cc79d30b..7d16276a942ca93f03621e65d4ee8980bb33f403 100644 (file)
@@ -1,5 +1,8 @@
 services:
     rapsys_pack.twig.pack_extension:
 services:
     rapsys_pack.twig.pack_extension:
-         class: Rapsys\PackBundle\Twig\PackExtension
-         arguments: [ '@file_locator', '@service_container' ]
-         tags: [ twig.extension ]
+        class: Rapsys\PackBundle\Twig\PackExtension
+        arguments: [ '@file_locator', '@service_container', '@assets.packages' ]
+        tags: [ twig.extension ]
+    rapsys_pack.twig.base64:
+        class: Rapsys\PackBundle\Twig\Base64Extension
+        tags: [ twig.extension ]
diff --git a/Twig/Base64Extension.php b/Twig/Base64Extension.php
new file mode 100644 (file)
index 0000000..6a0f3e2
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+// src/Rapsys/PackBundle/Twig/Base64Extension.php
+namespace Rapsys\PackBundle\Twig;
+
+class Base64Extension extends \Twig_Extension {
+       public function getFilters() {
+               return array(
+                       new \Twig_SimpleFilter('base64_encode', 'base64_encode'),
+                       new \Twig_SimpleFilter('base64_decode', 'base64_decode')
+               );
+       }
+}