From f806505f9a3a5f713008c3b8e4254a6c8b1fa14f Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 4 Mar 2019 13:53:50 +0300 Subject: [PATCH] Flextype Core: Assets Twig Extension - added --- flextype/twig/AssetsTwigExtension.php | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 flextype/twig/AssetsTwigExtension.php diff --git a/flextype/twig/AssetsTwigExtension.php b/flextype/twig/AssetsTwigExtension.php new file mode 100644 index 00000000..ba1bac6b --- /dev/null +++ b/flextype/twig/AssetsTwigExtension.php @@ -0,0 +1,35 @@ + + * @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\Assets\Assets; + +class AssetsTwigExtension extends \Twig_Extension +{ + /** + * Callback for twig. + * + * @return array + */ + public function getFunctions() + { + return [ + new \Twig_SimpleFunction('assets_get', array($this, 'get')), + ]; + } + + public function get(string $asset_type, string $namespace) : array + { + return Assets::get($asset_type, $namespace); + } +}