Rename ci attribute to container
This commit is contained in:
parent
0498b209b5
commit
27ceea2aee
2 changed files with 17 additions and 15 deletions
|
@ -22,11 +22,13 @@ class LoginController extends ShaarliController
|
||||||
{
|
{
|
||||||
public function index(Request $request, Response $response): Response
|
public function index(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
if ($this->ci->loginManager->isLoggedIn() || $this->ci->conf->get('security.open_shaarli', false)) {
|
if ($this->container->loginManager->isLoggedIn()
|
||||||
|
|| $this->container->conf->get('security.open_shaarli', false)
|
||||||
|
) {
|
||||||
return $response->withRedirect('./');
|
return $response->withRedirect('./');
|
||||||
}
|
}
|
||||||
|
|
||||||
$userCanLogin = $this->ci->loginManager->canLogin($request->getServerParams());
|
$userCanLogin = $this->container->loginManager->canLogin($request->getServerParams());
|
||||||
if ($userCanLogin !== true) {
|
if ($userCanLogin !== true) {
|
||||||
throw new LoginBannedException();
|
throw new LoginBannedException();
|
||||||
}
|
}
|
||||||
|
@ -37,8 +39,8 @@ public function index(Request $request, Response $response): Response
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->assignView('returnurl', escape($request->getServerParam('HTTP_REFERER')))
|
->assignView('returnurl', escape($request->getServerParam('HTTP_REFERER')))
|
||||||
->assignView('remember_user_default', $this->ci->conf->get('privacy.remember_user_default', true))
|
->assignView('remember_user_default', $this->container->conf->get('privacy.remember_user_default', true))
|
||||||
->assignView('pagetitle', t('Login') .' - '. $this->ci->conf->get('general.title', 'Shaarli'))
|
->assignView('pagetitle', t('Login') .' - '. $this->container->conf->get('general.title', 'Shaarli'))
|
||||||
;
|
;
|
||||||
|
|
||||||
return $response->write($this->render('loginform'));
|
return $response->write($this->render('loginform'));
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
abstract class ShaarliController
|
abstract class ShaarliController
|
||||||
{
|
{
|
||||||
/** @var ShaarliContainer */
|
/** @var ShaarliContainer */
|
||||||
protected $ci;
|
protected $container;
|
||||||
|
|
||||||
/** @param ShaarliContainer $ci Slim container (extended for attribute completion). */
|
/** @param ShaarliContainer $container Slim container (extended for attribute completion). */
|
||||||
public function __construct(ShaarliContainer $ci)
|
public function __construct(ShaarliContainer $container)
|
||||||
{
|
{
|
||||||
$this->ci = $ci;
|
$this->container = $container;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,20 +25,20 @@ public function __construct(ShaarliContainer $ci)
|
||||||
*/
|
*/
|
||||||
protected function assignView(string $name, $value): self
|
protected function assignView(string $name, $value): self
|
||||||
{
|
{
|
||||||
$this->ci->pageBuilder->assign($name, $value);
|
$this->container->pageBuilder->assign($name, $value);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function render(string $template): string
|
protected function render(string $template): string
|
||||||
{
|
{
|
||||||
$this->assignView('linkcount', $this->ci->bookmarkService->count(BookmarkFilter::$ALL));
|
$this->assignView('linkcount', $this->container->bookmarkService->count(BookmarkFilter::$ALL));
|
||||||
$this->assignView('privateLinkcount', $this->ci->bookmarkService->count(BookmarkFilter::$PRIVATE));
|
$this->assignView('privateLinkcount', $this->container->bookmarkService->count(BookmarkFilter::$PRIVATE));
|
||||||
$this->assignView('plugin_errors', $this->ci->pluginManager->getErrors());
|
$this->assignView('plugin_errors', $this->container->pluginManager->getErrors());
|
||||||
|
|
||||||
$this->executeDefaultHooks($template);
|
$this->executeDefaultHooks($template);
|
||||||
|
|
||||||
return $this->ci->pageBuilder->render($template);
|
return $this->container->pageBuilder->render($template);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,12 +55,12 @@ protected function executeDefaultHooks(string $template): void
|
||||||
|
|
||||||
foreach ($common_hooks as $name) {
|
foreach ($common_hooks as $name) {
|
||||||
$plugin_data = [];
|
$plugin_data = [];
|
||||||
$this->ci->pluginManager->executeHooks(
|
$this->container->pluginManager->executeHooks(
|
||||||
'render_' . $name,
|
'render_' . $name,
|
||||||
$plugin_data,
|
$plugin_data,
|
||||||
[
|
[
|
||||||
'target' => $template,
|
'target' => $template,
|
||||||
'loggedin' => $this->ci->loginManager->isLoggedIn()
|
'loggedin' => $this->container->loginManager->isLoggedIn()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assignView('plugins_' . $name, $plugin_data);
|
$this->assignView('plugins_' . $name, $plugin_data);
|
||||||
|
|
Loading…
Reference in a new issue