. // }}} /** * GNU social Twig extensions * * @package GNUsocial * @category Twig * * @author Hugo Sales * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ namespace App\Twig; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; use Twig\TwigTest; class Extension extends AbstractExtension { public function getFilters() { return [ // new TwigFilter('foo', [GSRuntime::class, 'foo']), ]; } public function getTests() { return [ new TwigTest('instanceof', [Runtime::class, 'isInstanceOf']), ]; } /** * get twig functions * * @return array|TwigFunction[] */ public function getFunctions() { return [ /** Twig function to output the 'active' class if the current route matches the given route */ new TwigFunction('active', [Runtime::class, 'isCurrentRouteActive']), new TwigFunction('is_route', [Runtime::class, 'isCurrentRoute']), new TwigFunction('get_note_actions', [Runtime::class, 'getNoteActions']), new TwigFunction('show_stylesheets', [Runtime::class, 'getShowStylesheets']), new TwigFunction('handle_event', [Runtime::class, 'handleEvent']), new TwigFunction('config', [Runtime::class, 'getConfig']), new TwigFunction('icon', [Runtime::class, 'embedSvgIcon'], ['needs_environment' => true]), new TwigFunction('is_firefox', [Runtime::class, 'isFirefox']), ]; } }