From fee581d91306884c72dac3f03c865112c0bd974a Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 25 Apr 2019 16:45:24 +0300 Subject: [PATCH] Flextype: FilesystemTwigExtension - added --- flextype/twig/FilesystemTwigExtension.php | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 flextype/twig/FilesystemTwigExtension.php diff --git a/flextype/twig/FilesystemTwigExtension.php b/flextype/twig/FilesystemTwigExtension.php new file mode 100644 index 00000000..4f1618c3 --- /dev/null +++ b/flextype/twig/FilesystemTwigExtension.php @@ -0,0 +1,41 @@ + + * @link http://romanenko.digital + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flextype; + +use Flextype\Component\Filesystem\Filesystem; + +class FilesystemTwigExtension extends \Twig_Extension +{ + /** + * Callback for twig. + * + * @return array + */ + public function getFunctions() + { + return [ + new \Twig_SimpleFunction('filesystem_has', array($this, 'filesystem_has')), + new \Twig_SimpleFunction('filesystem_read', array($this, 'filesystem_read')), + ]; + } + + public function has($path) + { + return Filesystem::has($path); + } + + public function read($path) + { + return Filesystem::read($path); + } +}