From 184d0246a58f3a40111b1d19557d45df8e187204 Mon Sep 17 00:00:00 2001 From: Eliseu Amaro Date: Mon, 17 Jan 2022 01:36:12 +0000 Subject: [PATCH] [COMPONENTS][RightPanel] AppendRightPanelBlock event refactored, replaced with src/Twig/Rintime::getRightPanelBlocks [COMPONENTS] Re-ordered onAppendRightPanelBlock event calls arguments for improved consistency across events --- components/Collection/Util/MetaCollectionTrait.php | 2 +- components/Group/Controller/Group.php | 9 +++++++++ .../RightPanel/templates/right_panel/view.html.twig | 6 +++--- plugins/AttachmentShowRelated/AttachmentShowRelated.php | 3 ++- plugins/WebMonetization/WebMonetization.php | 2 +- src/Twig/Extension.php | 1 + src/Twig/Runtime.php | 7 +++++++ 7 files changed, 24 insertions(+), 6 deletions(-) diff --git a/components/Collection/Util/MetaCollectionTrait.php b/components/Collection/Util/MetaCollectionTrait.php index 3ac6f4247e..531d37aeaa 100644 --- a/components/Collection/Util/MetaCollectionTrait.php +++ b/components/Collection/Util/MetaCollectionTrait.php @@ -94,7 +94,7 @@ trait MetaCollectionTrait * It's compose of two forms: one to select collections to add * the current item to, and another to create a new collection. */ - public function onAppendRightPanelBlock($vars, Request $request, &$res): bool + public function onAppendRightPanelBlock(Request $request, $vars, &$res): bool { $user = Common::actor(); if (\is_null($user)) { diff --git a/components/Group/Controller/Group.php b/components/Group/Controller/Group.php index a7dc634e59..2e55f44439 100644 --- a/components/Group/Controller/Group.php +++ b/components/Group/Controller/Group.php @@ -59,6 +59,15 @@ class Group extends FeedController /** * View a group feed and give the option of creating it if it doesn't exist + * + * @throws \App\Util\Exception\NicknameEmptyException + * @throws \App\Util\Exception\NicknameNotAllowedException + * @throws \App\Util\Exception\NicknameTakenException + * @throws \App\Util\Exception\NicknameTooLongException + * @throws \App\Util\Exception\ServerException + * @throws RedirectException + * + * @return array */ public function groupViewNickname(Request $request, string $nickname) { diff --git a/components/RightPanel/templates/right_panel/view.html.twig b/components/RightPanel/templates/right_panel/view.html.twig index 8ebd45d043..aeb6c239a0 100644 --- a/components/RightPanel/templates/right_panel/view.html.twig +++ b/components/RightPanel/templates/right_panel/view.html.twig @@ -7,6 +7,7 @@
{% endblock rightpanel %} diff --git a/plugins/AttachmentShowRelated/AttachmentShowRelated.php b/plugins/AttachmentShowRelated/AttachmentShowRelated.php index 7f0007c53d..e8ea8016e4 100644 --- a/plugins/AttachmentShowRelated/AttachmentShowRelated.php +++ b/plugins/AttachmentShowRelated/AttachmentShowRelated.php @@ -28,10 +28,11 @@ use App\Core\Event; use App\Core\Modules\Plugin; use App\Util\Common; use App\Util\Formatting; +use Symfony\Component\HttpFoundation\Request; class AttachmentShowRelated extends Plugin { - public function onAppendRightPanelBlock($vars, $request, &$res): bool + public function onAppendRightPanelBlock(Request $request, $vars, &$res): bool { if ($vars['path'] === 'note_attachment_show') { $related_notes = DB::dql('select n from attachment_to_note an ' diff --git a/plugins/WebMonetization/WebMonetization.php b/plugins/WebMonetization/WebMonetization.php index c05f62b5fd..8f3300d62e 100644 --- a/plugins/WebMonetization/WebMonetization.php +++ b/plugins/WebMonetization/WebMonetization.php @@ -51,7 +51,7 @@ use Symfony\Component\HttpFoundation\Request; class WebMonetization extends Plugin { - public function onAppendRightPanelBlock($vars, Request $request, &$res): bool + public function onAppendRightPanelBlock(Request $request, $vars, &$res): bool { $user = Common::actor(); if (\is_null($user)) { diff --git a/src/Twig/Extension.php b/src/Twig/Extension.php index 3a1adead60..ec031f4787 100644 --- a/src/Twig/Extension.php +++ b/src/Twig/Extension.php @@ -78,6 +78,7 @@ class Extension extends AbstractExtension new TwigFunction('mention', [Runtime::class, 'mention']), new TwigFunction('open_details', [Runtime::class, 'openDetails']), new TwigFunction('show_stylesheets', [Runtime::class, 'getShowStylesheets']), + new TwigFunction('get_right_panel_blocks', [Runtime::class, 'getRightPanelBlocks']), ]; } } diff --git a/src/Twig/Runtime.php b/src/Twig/Runtime.php index 0e036dbcfa..53710538bb 100644 --- a/src/Twig/Runtime.php +++ b/src/Twig/Runtime.php @@ -88,6 +88,13 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface return $extra_actions; } + public function getRightPanelBlocks($vars) + { + $blocks = []; + Event::handle('AppendRightPanelBlock', [$this->request, $vars, &$blocks]); + return $blocks; + } + /** * @codeCoverageIgnore */