Refactor App, add AppHelper in constructor

This commit is contained in:
Art4 2024-11-06 12:26:33 +00:00
parent 00d2e24dd2
commit b5317f8e46

View file

@ -125,6 +125,11 @@ class App
*/ */
private $session; private $session;
/**
* @var AppHelper $appHelper
*/
private $appHelper;
/** /**
* Set the profile owner ID * Set the profile owner ID
* *
@ -156,7 +161,7 @@ class App
*/ */
public function setContactId(int $contact_id) public function setContactId(int $contact_id)
{ {
DI::apphelper()->setContactId($contact_id); $this->appHelper->setContactId($contact_id);
} }
/** /**
@ -168,7 +173,7 @@ class App
*/ */
public function getContactId(): int public function getContactId(): int
{ {
return DI::apphelper()->getContactId(); return $this->appHelper->getContactId();
} }
/** /**
@ -181,7 +186,7 @@ class App
*/ */
public function setTimeZone(string $timezone) public function setTimeZone(string $timezone)
{ {
DI::apphelper()->setTimeZone($timezone); $this->appHelper->setTimeZone($timezone);
} }
/** /**
@ -191,7 +196,7 @@ class App
*/ */
public function getTimeZone(): string public function getTimeZone(): string
{ {
return DI::apphelper()->getTimeZone(); return $this->appHelper->getTimeZone();
} }
/** /**
@ -303,6 +308,7 @@ class App
$this->args = $args; $this->args = $args;
$this->pConfig = $pConfig; $this->pConfig = $pConfig;
$this->session = $session; $this->session = $session;
$this->appHelper = DI::apphelper();
$this->load($dbaDefinition, $viewDefinition); $this->load($dbaDefinition, $viewDefinition);
} }
@ -367,7 +373,7 @@ class App
$timezone = $default_timezone ?? '' ?: 'UTC'; $timezone = $default_timezone ?? '' ?: 'UTC';
} }
DI::apphelper()->setTimeZone($timezone); $this->appHelper->setTimeZone($timezone);
} }
/** /**