[TWIG][EndShowStyles] Route as an event argument

このコミットが含まれているのは:
Eliseu Amaro 2021-10-06 00:34:27 +01:00
コミット 3cb6563c40
6個のファイルの変更22行の追加7行の削除

ファイルの表示

@ -31,7 +31,7 @@ class Left extends Component
*
* @return bool hook value; true means continue processing, false means stop.
*/
public function onEndShowStyles(array &$styles): bool
public function onEndShowStyles(array &$styles, string $route): bool
{
$styles[] = 'components/Left/assets/css/view.css';
return Event::next;

ファイルの表示

@ -31,7 +31,7 @@ class Right extends Component
*
* @return bool hook value; true means continue processing, false means stop.
*/
public function onEndShowStyles(array &$styles): bool
public function onEndShowStyles(array &$styles, string $route): bool
{
$styles[] = 'components/Right/assets/css/view.css';
return Event::next;

ファイルの表示

@ -76,7 +76,7 @@ class Search extends Component
*
* @return bool hook value; true means continue processing, false means stop.
*/
public function onEndShowStyles(array &$styles): bool
public function onEndShowStyles(array &$styles, string $route): bool
{
$styles[] = 'components/Search/assets/css/view.css';
return Event::next;

ファイルの表示

@ -31,7 +31,7 @@ class AttachmentShowRelated extends Plugin
{
public function onAppendRightPanelBlock($vars, &$res): bool
{
if ($vars['path'] == 'attachment_show') {
if ($vars['path'] === 'attachment_show') {
$related_notes = DB::dql('select n from attachment_to_note an ' .
'join note n with n.id = an.note_id ' .
'where an.attachment_id = :attachment_id', ['attachment_id' => $vars['vars']['attachment_id']]);
@ -43,4 +43,19 @@ class AttachmentShowRelated extends Plugin
}
return Event::next;
}
/**
* Output our dedicated stylesheet
*
* @param array $styles stylesheets path
*
* @return bool hook value; true means continue processing, false means stop.
*/
public function onEndShowStyles(array &$styles, string $path): bool
{
if ($path === 'attachment_show') {
$styles[] = '/assets/default_theme/css/pages/feeds.css';
}
return Event::next;
}
}

ファイルの表示

@ -82,10 +82,10 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface
* @return array|mixed
* @codeCoverageIgnore
*/
public function getShowStylesheets()
public function getShowStylesheets($route)
{
$styles = [];
Event::handle('EndShowStyles', [&$styles]);
Event::handle('EndShowStyles', [&$styles, $route]);
return $styles;
}

ファイルの表示

@ -15,7 +15,7 @@
<link rel="preload" href="{{ asset('assets/default_theme/css/base.css') }}" as="style" type="text/css">
<link rel="stylesheet" href="{{ asset('assets/default_theme/css/base.css') }}">
{% for stylesheet in show_stylesheets() %}
{% for stylesheet in show_stylesheets(app.request.get('_route')) %}
<link rel='stylesheet' type='text/css' href="{{ asset(stylesheet) }}">
{% endfor %}
{% endblock %}