Browse Source

[TWIG][EndShowStyles] Route as an event argument

remotes/upstream/experimental
Eliseu Amaro 7 months ago
parent
commit
3cb6563c40
6 changed files with 22 additions and 7 deletions
  1. +1
    -1
      components/Left/Left.php
  2. +1
    -1
      components/Right/Right.php
  3. +1
    -1
      components/Search/Search.php
  4. +16
    -1
      plugins/AttachmentShowRelated/AttachmentShowRelated.php
  5. +2
    -2
      src/Twig/Runtime.php
  6. +1
    -1
      templates/base.html.twig

+ 1
- 1
components/Left/Left.php View File

@@ -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;


+ 1
- 1
components/Right/Right.php View File

@@ -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;


+ 1
- 1
components/Search/Search.php View File

@@ -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;


+ 16
- 1
plugins/AttachmentShowRelated/AttachmentShowRelated.php View File

@@ -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;
}
}

+ 2
- 2
src/Twig/Runtime.php View File

@@ -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;
}



+ 1
- 1
templates/base.html.twig View File

@@ -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 %}


Loading…
Cancel
Save