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); + } +}