3 declare(strict_types
=1);
5 namespace Shaarli\Front\Controller
;
7 use Shaarli\Bookmark\BookmarkFilter
;
8 use Shaarli\Container\ShaarliContainer
;
10 abstract class ShaarliController
12 /** @var ShaarliContainer */
15 /** @param ShaarliContainer $ci Slim container (extended for attribute completion). */
16 public function __construct(ShaarliContainer
$ci)
22 * Assign variables to RainTPL template through the PageBuilder.
24 * @param mixed $value Value to assign to the template
26 protected function assignView(string $name, $value): self
28 $this->ci
->pageBuilder
->assign($name, $value);
33 protected function render(string $template): string
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());
39 $this->executeDefaultHooks($template);
41 return $this->ci
->pageBuilder
->render($template);
45 * Call plugin hooks for header, footer and includes, specifying which page will be rendered.
46 * Then assign generated data to RainTPL.
48 protected function executeDefaultHooks(string $template): void
56 foreach ($common_hooks as $name) {
58 $this->ci
->pluginManager
->executeHooks(
62 'target' => $template,
63 'loggedin' => $this->ci
->loginManager
->isLoggedIn()
66 $this->assignView('plugins_' . $name, $plugin_data);