1
1
Fork 0

Move DI dependency for App\Page class

This commit is contained in:
Philipp Holzer 2022-10-20 21:27:32 +02:00
parent b3f9cef94a
commit f83784cc63
Signed by: nupplaPhil
GPG key ID: 24A7501396EB5432
3 changed files with 17 additions and 13 deletions

View file

@ -45,6 +45,7 @@ $a->runFrontend(
$dice->create(\Friendica\Core\PConfig\Capability\IManagePersonalConfigValues::class),
$dice->create(\Friendica\Security\Authentication::class),
$dice->create(\Friendica\App\Page::class),
$dice->create(\Friendica\Core\Session\Capability\IHandleUserSessions::class),
new \Friendica\Util\HTTPInputData($_SERVER),
$start_time
);

View file

@ -27,6 +27,7 @@ use Friendica\App\BaseURL;
use Friendica\Capabilities\ICanCreateResponses;
use Friendica\Core\Config\Factory\Config;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Module\Maintenance;
use Friendica\Security\Authentication;
use Friendica\Core\Config\ValueObject\Cache;
@ -592,12 +593,13 @@ class App
* @param Authentication $auth The Authentication backend of the node
* @param App\Page $page The Friendica page printing container
* @param HTTPInputData $httpInput A library for processing PHP input streams
* @param IHandleUserSessions $userSessions The UserSession class
* @param float $start_time The start time of the overall script execution
*
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
public function runFrontend(App\Router $router, IManagePersonalConfigValues $pconfig, Authentication $auth, App\Page $page, HTTPInputData $httpInput, float $start_time)
public function runFrontend(App\Router $router, IManagePersonalConfigValues $pconfig, Authentication $auth, App\Page $page, HTTPInputData $httpInput, IHandleUserSessions $userSessions, float $start_time)
{
$this->profiler->set($start_time, 'start');
$this->profiler->set(microtime(true), 'classinit');
@ -736,7 +738,7 @@ class App
$response = $module->run($input);
$this->profiler->set(microtime(true) - $timestamp, 'content');
if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML) {
$page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig);
$page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig, $userSessions->getLocalUserId());
} else {
$page->exit($response);
}

View file

@ -34,7 +34,6 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\DI;
use Friendica\Module\Response;
use Friendica\Network\HTTPException;
use Friendica\Util\Network;
@ -222,17 +221,18 @@ class Page implements ArrayAccess
* - Infinite scroll data
* - head.tpl template
*
* @param App $app The Friendica App instance
* @param Arguments $args The Friendica App Arguments
* @param L10n $l10n The l10n language instance
* @param IManageConfigValues $config The Friendica configuration
* @param IManagePersonalConfigValues $pConfig The Friendica personal configuration (for user)
* @param App $app The Friendica App instance
* @param Arguments $args The Friendica App Arguments
* @param L10n $l10n The l10n language instance
* @param IManageConfigValues $config The Friendica configuration
* @param IManagePersonalConfigValues $pConfig The Friendica personal configuration (for user)
* @param int $localUID The local user id
*
* @throws HTTPException\InternalServerErrorException
*/
private function initHead(App $app, Arguments $args, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig)
private function initHead(App $app, Arguments $args, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, int $localUID)
{
$interval = ((DI::userSession()->getLocalUserId()) ? $pConfig->get(DI::userSession()->getLocalUserId(), 'system', 'update_interval') : 40000);
$interval = ($localUID ? $pConfig->get($localUID, 'system', 'update_interval') : 40000);
// If the update is 'deactivated' set it to the highest integer number (~24 days)
if ($interval < 0) {
@ -277,7 +277,7 @@ class Page implements ArrayAccess
* being first
*/
$this->page['htmlhead'] = Renderer::replaceMacros($tpl, [
'$local_user' => DI::userSession()->getLocalUserId(),
'$local_user' => $localUID,
'$generator' => 'Friendica' . ' ' . App::VERSION,
'$delitem' => $l10n->t('Delete this item?'),
'$blockAuthor' => $l10n->t('Block this author? They won\'t be able to follow you nor see your public posts, and you won\'t be able to see their posts and their notifications.'),
@ -444,10 +444,11 @@ class Page implements ArrayAccess
* @param L10n $l10n The l10n language class
* @param IManageConfigValues $config The Configuration of this node
* @param IManagePersonalConfigValues $pconfig The personal/user configuration
* @param int $localUID The UID of the local user
*
* @throws HTTPException\InternalServerErrorException|HTTPException\ServiceUnavailableException
*/
public function run(App $app, BaseURL $baseURL, Arguments $args, Mode $mode, ResponseInterface $response, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig)
public function run(App $app, BaseURL $baseURL, Arguments $args, Mode $mode, ResponseInterface $response, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig, int $localUID)
{
$moduleName = $args->getModuleName();
@ -481,7 +482,7 @@ class Page implements ArrayAccess
* all the module functions have executed so that all
* theme choices made by the modules can take effect.
*/
$this->initHead($app, $args, $l10n, $config, $pconfig);
$this->initHead($app, $args, $l10n, $config, $pconfig, $localUID);
/* Build the page ending -- this is stuff that goes right before
* the closing </body> tag