aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/front/controllers/ShaarliController.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-01-23 20:06:32 +0100
committerArthurHoaro <arthur@hoa.ro>2020-01-26 11:34:14 +0100
commit0498b209b551cad5595312583e5d6fb1bc3303a5 (patch)
treea7b176fc39788bc7f5eef1ddcd18877d2defdfd9 /application/front/controllers/ShaarliController.php
parent9e4cc28e2957e1f7df713d52a03e350d728dc58e (diff)
downloadShaarli-0498b209b551cad5595312583e5d6fb1bc3303a5.tar.gz
Shaarli-0498b209b551cad5595312583e5d6fb1bc3303a5.tar.zst
Shaarli-0498b209b551cad5595312583e5d6fb1bc3303a5.zip
Execute common plugin hooks before rendering login page
Diffstat (limited to 'application/front/controllers/ShaarliController.php')
-rw-r--r--application/front/controllers/ShaarliController.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/application/front/controllers/ShaarliController.php b/application/front/controllers/ShaarliController.php
index 2a166c3c..99e66d53 100644
--- a/application/front/controllers/ShaarliController.php
+++ b/application/front/controllers/ShaarliController.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
4 4
5namespace Shaarli\Front\Controller; 5namespace Shaarli\Front\Controller;
6 6
7use Shaarli\Bookmark\BookmarkFilter;
7use Shaarli\Container\ShaarliContainer; 8use Shaarli\Container\ShaarliContainer;
8 9
9abstract class ShaarliController 10abstract class ShaarliController
@@ -28,4 +29,41 @@ abstract class ShaarliController
28 29
29 return $this; 30 return $this;
30 } 31 }
32
33 protected function render(string $template): string
34 {
35 $this->assignView('linkcount', $this->ci->bookmarkService->count(BookmarkFilter::$ALL));
36 $this->assignView('privateLinkcount', $this->ci->bookmarkService->count(BookmarkFilter::$PRIVATE));
37 $this->assignView('plugin_errors', $this->ci->pluginManager->getErrors());
38
39 $this->executeDefaultHooks($template);
40
41 return $this->ci->pageBuilder->render($template);
42 }
43
44 /**
45 * Call plugin hooks for header, footer and includes, specifying which page will be rendered.
46 * Then assign generated data to RainTPL.
47 */
48 protected function executeDefaultHooks(string $template): void
49 {
50 $common_hooks = [
51 'includes',
52 'header',
53 'footer',
54 ];
55
56 foreach ($common_hooks as $name) {
57 $plugin_data = [];
58 $this->ci->pluginManager->executeHooks(
59 'render_' . $name,
60 $plugin_data,
61 [
62 'target' => $template,
63 'loggedin' => $this->ci->loginManager->isLoggedIn()
64 ]
65 );
66 $this->assignView('plugins_' . $name, $plugin_data);
67 }
68 }
31} 69}