[Favourite] Make twig event operate on array rather than string
This commit is contained in:
parent
7a90e844b7
commit
8dff0b1d0c
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
// {{{ 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
|
||||
@ -15,6 +16,7 @@
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
// }}}
|
||||
|
||||
namespace Plugin\Favourite;
|
||||
@ -75,7 +77,7 @@ class Favourite extends Plugin
|
||||
|
||||
public function onInsertLeftPanelLink(string $user_nickname, &$res)
|
||||
{
|
||||
$res .= Formatting::twigRender(<<<END
|
||||
$res[] = Formatting::twigRender(<<<END
|
||||
<a href="{{ path("favourites", {'nickname' : user_nickname}) }}" class='hover-effect {{ active("favourites") }}'>Favourites</a>
|
||||
<a href="{{ path("reverse_favourites", {'nickname' : user_nickname}) }}" class='hover-effect {{ active("reverse_favourites") }}'>Reverse Favs</a>
|
||||
END, ['user_nickname' => $user_nickname]);
|
||||
|
@ -55,7 +55,7 @@ class Extension extends AbstractExtension
|
||||
new TwigFunction('is_route', [Runtime::class, 'isCurrentRoute']),
|
||||
new TwigFunction('get_note_actions', [Runtime::class, 'getNoteActions']),
|
||||
new TwigFunction('get_note_other_content', [Runtime::class, 'getNoteOtherContent']),
|
||||
new TwigFunction('get_show_styles', [Runtime::class, 'getShowStyles']),
|
||||
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]),
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
// {{{ 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
|
||||
@ -16,7 +15,6 @@
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
// }}}
|
||||
|
||||
/**
|
||||
@ -95,16 +93,16 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface
|
||||
*
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function getShowStyles()
|
||||
public function getShowStylesheets()
|
||||
{
|
||||
$styles = [];
|
||||
Event::handle('start_show_styles',[&$styles]);
|
||||
return $styles;
|
||||
Event::handle('ShowStyles', [&$styles]);
|
||||
return implode("\n", $styles);
|
||||
}
|
||||
|
||||
public function handleEvent(string $event, ...$args)
|
||||
{
|
||||
$res = '';
|
||||
$res = [];
|
||||
$args[] = &$res;
|
||||
Event::handle($event, $args);
|
||||
return $res;
|
||||
|
@ -14,10 +14,13 @@
|
||||
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/base_mid.css') }}" media="screen and (max-width: 1300px)">
|
||||
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/base_small.css') }}" media="screen and (max-width: 750px)">
|
||||
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/reset.css') }}">
|
||||
{% for stylesheet in get_show_styles() %}
|
||||
{% for stylesheet in show_stylesheets() %}
|
||||
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/' ~ stylesheet) }}">
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% for type, element in handle_event('ShowHeadElements', app.request) %}
|
||||
<{{type}} rel="{{element['rel']}}" type="{{element['type']}}" href="{{element['href']}}" title="{{element['title']}}">
|
||||
{% endfor %}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
@ -44,7 +44,9 @@
|
||||
</div>
|
||||
<a href='#'>Messages</a>
|
||||
<a href="{{ path("replies", {'nickname' : user_nickname}) }}" class='hover-effect {{ active("replies") }}'>Replies</a>
|
||||
{{ handle_event('InsertLeftPanelLink', user_nickname) | raw }}
|
||||
{% for link in handle_event('InsertLeftPanelLink', user_nickname) %}
|
||||
{{ link | raw }}
|
||||
{% endfor %}
|
||||
<a href="{{ path('settings_personal_info') }}" class='hover-effect {{ active('settings_') }}'>Settings</a>
|
||||
<a href='{{ path('logout') }}'>Logout</a>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user