2020-07-23 23:48:59 +01:00
|
|
|
<?php
|
|
|
|
|
2021-10-10 09:26:18 +01:00
|
|
|
declare(strict_types = 1);
|
|
|
|
|
2020-07-23 23:48:59 +01:00
|
|
|
// {{{ License
|
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// GNU social is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GNU social Twig extensions
|
|
|
|
*
|
|
|
|
* @package GNUsocial
|
|
|
|
* @category Twig
|
|
|
|
*
|
2021-02-19 23:29:43 +00:00
|
|
|
* @author Hugo Sales <hugo@hsal.es>
|
|
|
|
* @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
|
2020-07-23 23:48:59 +01:00
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Twig;
|
|
|
|
|
|
|
|
use Twig\Extension\AbstractExtension;
|
|
|
|
use Twig\TwigFunction;
|
2021-09-27 10:38:06 +01:00
|
|
|
use Twig\TwigTest;
|
2020-07-23 23:48:59 +01:00
|
|
|
|
|
|
|
class Extension extends AbstractExtension
|
|
|
|
{
|
|
|
|
public function getFilters()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
// new TwigFilter('foo', [GSRuntime::class, 'foo']),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2021-09-27 10:38:06 +01:00
|
|
|
public function getTests()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
new TwigTest('instanceof', [Runtime::class, 'isInstanceOf']),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2020-11-23 15:06:23 +00:00
|
|
|
/**
|
|
|
|
* get twig functions
|
|
|
|
*
|
|
|
|
* @return array|TwigFunction[]
|
|
|
|
*/
|
2021-10-10 09:26:18 +01:00
|
|
|
public function getFunctions(): array
|
2020-07-23 23:48:59 +01:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
/** Twig function to output the 'active' class if the current route matches the given route */
|
|
|
|
new TwigFunction('active', [Runtime::class, 'isCurrentRouteActive']),
|
2021-12-27 04:13:09 +00:00
|
|
|
new TwigFunction('config', [Runtime::class, 'getConfig']),
|
|
|
|
new TwigFunction('dd', 'dd'),
|
|
|
|
new TwigFunction('die', 'die'),
|
2021-12-04 11:59:45 +00:00
|
|
|
new TwigFunction('get_extra_note_actions', [Runtime::class, 'getExtraNoteActions']),
|
2021-12-27 04:13:09 +00:00
|
|
|
new TwigFunction('get_feeds', [Runtime::class, 'getFeeds']),
|
|
|
|
new TwigFunction('get_note_actions', [Runtime::class, 'getNoteActions']),
|
2021-04-15 01:59:30 +01:00
|
|
|
new TwigFunction('handle_event', [Runtime::class, 'handleEvent']),
|
2021-12-27 04:13:09 +00:00
|
|
|
new TwigFunction('handle_override_stylesheet', [Runtime::class, 'handleOverrideStylesheet']),
|
|
|
|
new TwigFunction('handle_override_template_import', [Runtime::class, 'handleOverrideTemplateImport']),
|
2020-10-20 23:38:56 +01:00
|
|
|
new TwigFunction('icon', [Runtime::class, 'embedSvgIcon'], ['needs_environment' => true]),
|
2021-09-07 15:20:28 +01:00
|
|
|
new TwigFunction('is_firefox', [Runtime::class, 'isFirefox']),
|
2021-12-27 04:13:09 +00:00
|
|
|
new TwigFunction('is_route', [Runtime::class, 'isCurrentRoute']),
|
|
|
|
new TwigFunction('mention', [Runtime::class, 'mention']),
|
2021-11-15 13:34:34 +00:00
|
|
|
new TwigFunction('open_details', [Runtime::class, 'openDetails']),
|
2021-12-27 04:13:09 +00:00
|
|
|
new TwigFunction('show_stylesheets', [Runtime::class, 'getShowStylesheets']),
|
2020-07-23 23:48:59 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|