Rename DI::apphelper() to DI::appHeler()

This commit is contained in:
Art4 2024-11-17 20:00:34 +00:00
parent e320b010c7
commit 603af2fb19
31 changed files with 44 additions and 44 deletions

View file

@ -284,7 +284,7 @@ function item_process(array $post, array $request, bool $preview, string $return
unset($post['api_source']); unset($post['api_source']);
if (!empty($request['scheduled_at'])) { if (!empty($request['scheduled_at'])) {
$scheduled_at = DateTimeFormat::convert($request['scheduled_at'], 'UTC', DI::apphelper()->getTimeZone()); $scheduled_at = DateTimeFormat::convert($request['scheduled_at'], 'UTC', DI::appHelper()->getTimeZone());
if ($scheduled_at > DateTimeFormat::utcNow()) { if ($scheduled_at > DateTimeFormat::utcNow()) {
unset($post['created']); unset($post['created']);
unset($post['edited']); unset($post['edited']);

View file

@ -129,7 +129,7 @@ class App implements AppHelper
$this->l10n = $l10n; $this->l10n = $l10n;
$this->args = $args; $this->args = $args;
$this->session = $session; $this->session = $session;
$this->appHelper = DI::apphelper(); $this->appHelper = DI::appHelper();
$this->load($dbaDefinition, $viewDefinition); $this->load($dbaDefinition, $viewDefinition);
} }

View file

@ -58,7 +58,7 @@ HELP;
$this->appMode = $appMode; $this->appMode = $appMode;
$this->keyValue = $keyValue; $this->keyValue = $keyValue;
$this->l10n = $l10n; $this->l10n = $l10n;
$this->basePath = DI::apphelper()->getBasePath(); $this->basePath = DI::appHelper()->getBasePath();
} }
protected function doExecute(): int protected function doExecute(): int

View file

@ -48,7 +48,7 @@ class OEmbed
{ {
$embedurl = trim($embedurl, '\'"'); $embedurl = trim($embedurl, '\'"');
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
$cache_key = 'oembed:' . $appHelper->getThemeInfoValue('videowidth') . ':' . $embedurl; $cache_key = 'oembed:' . $appHelper->getThemeInfoValue('videowidth') . ':' . $embedurl;

View file

@ -1926,7 +1926,7 @@ class BBCode
private static function convertVideoPlatformsToHtml(string $text, bool $try_oembed): string private static function convertVideoPlatformsToHtml(string $text, bool $try_oembed): string
{ {
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
$text = self::normalizeVideoLinks($text); $text = self::normalizeVideoLinks($text);

View file

@ -80,7 +80,7 @@ class Hook
*/ */
public static function register(string $hook, string $file, string $function, int $priority = 0) public static function register(string $hook, string $file, string $function, int $priority = 0)
{ {
$file = str_replace(DI::apphelper()->getBasePath() . DIRECTORY_SEPARATOR, '', $file); $file = str_replace(DI::appHelper()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function]; $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
if (DBA::exists('hook', $condition)) { if (DBA::exists('hook', $condition)) {
@ -101,7 +101,7 @@ class Hook
*/ */
public static function unregister(string $hook, string $file, string $function): bool public static function unregister(string $hook, string $file, string $function): bool
{ {
$relative_file = str_replace(DI::apphelper()->getBasePath() . DIRECTORY_SEPARATOR, '', $file); $relative_file = str_replace(DI::appHelper()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
// This here is only needed for fixing a problem that existed on the develop branch // This here is only needed for fixing a problem that existed on the develop branch
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function]; $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
@ -197,7 +197,7 @@ class Hook
public static function callSingle(string $name, array $hook, &$data = null) public static function callSingle(string $name, array $hook, &$data = null)
{ {
// Don't run a theme's hook if the user isn't using the theme // Don't run a theme's hook if the user isn't using the theme
if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/' . DI::apphelper()->getCurrentTheme()) === false) { if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/' . DI::appHelper()->getCurrentTheme()) === false) {
return; return;
} }

View file

@ -155,7 +155,7 @@ class Renderer
if (isset(self::$template_engine_instance[$template_engine])) { if (isset(self::$template_engine_instance[$template_engine])) {
return self::$template_engine_instance[$template_engine]; return self::$template_engine_instance[$template_engine];
} else { } else {
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
$class = self::$template_engines[$template_engine]; $class = self::$template_engines[$template_engine];
$obj = new $class($appHelper->getCurrentTheme(), $appHelper->getThemeInfo()); $obj = new $class($appHelper->getCurrentTheme(), $appHelper->getThemeInfo());
self::$template_engine_instance[$template_engine] = $obj; self::$template_engine_instance[$template_engine] = $obj;

View file

@ -208,7 +208,7 @@ class Theme
*/ */
public static function getPathForFile(string $file): string public static function getPathForFile(string $file): string
{ {
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
$theme = $appHelper->getCurrentTheme(); $theme = $appHelper->getCurrentTheme();
@ -245,7 +245,7 @@ class Theme
return 'view/theme/' . $theme . '/style.css'; return 'view/theme/' . $theme . '/style.css';
} }
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
$query_params = []; $query_params = [];
@ -267,7 +267,7 @@ class Theme
{ {
$theme = Strings::sanitizeFilePathItem($theme); $theme = Strings::sanitizeFilePathItem($theme);
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
$base_theme = $appHelper->getThemeInfoValue('extends') ?? ''; $base_theme = $appHelper->getThemeInfoValue('extends') ?? '';
if (file_exists("view/theme/$theme/config.php")) { if (file_exists("view/theme/$theme/config.php")) {

View file

@ -533,7 +533,7 @@ class Worker
*/ */
private static function execFunction(array $queue, string $funcname, array $argv, bool $method_call) private static function execFunction(array $queue, string $funcname, array $argv, bool $method_call)
{ {
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
self::coolDown(); self::coolDown();
@ -1371,7 +1371,7 @@ class Worker
*/ */
public static function getRetrial(): int public static function getRetrial(): int
{ {
$queue = DI::apphelper()->getQueue(); $queue = DI::appHelper()->getQueue();
return $queue['retrial'] ?? 0; return $queue['retrial'] ?? 0;
} }
@ -1384,7 +1384,7 @@ class Worker
*/ */
public static function defer(int $worker_defer_limit = 0): bool public static function defer(int $worker_defer_limit = 0): bool
{ {
$queue = DI::apphelper()->getQueue(); $queue = DI::appHelper()->getQueue();
if (empty($queue)) { if (empty($queue)) {
return false; return false;

View file

@ -71,7 +71,7 @@ abstract class DI
// //
/** /**
* @deprecated 2024.12 use DI::apphelper() instead * @deprecated 2024.12 use DI::appHelper() instead
* *
* @return App * @return App
*/ */
@ -80,7 +80,7 @@ abstract class DI
return self::$dice->create(App::class); return self::$dice->create(App::class);
} }
public static function apphelper(): AppHelper public static function appHelper(): AppHelper
{ {
return self::$dice->create(AppHelper::class); return self::$dice->create(AppHelper::class);
} }

View file

@ -3348,7 +3348,7 @@ class Item
*/ */
public static function prepareBody(array &$item, bool $attach = false, bool $is_preview = false, bool $only_cache = false): string public static function prepareBody(array &$item, bool $attach = false, bool $is_preview = false, bool $only_cache = false): string
{ {
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
$uid = DI::userSession()->getLocalUserId(); $uid = DI::userSession()->getLocalUserId();
Hook::callAll('prepare_body_init', $item); Hook::callAll('prepare_body_init', $item);

View file

@ -29,7 +29,7 @@ class Summary extends BaseAdmin
{ {
parent::content(); parent::content();
$basePath = DI::apphelper()->getBasePath(); $basePath = DI::appHelper()->getBasePath();
// are there MyISAM tables in the DB? If so, trigger a warning message // are there MyISAM tables in the DB? If so, trigger a warning message
$warningtext = []; $warningtext = [];

View file

@ -59,11 +59,11 @@ class Create extends BaseApi
$finish = DBA::NULL_DATETIME; $finish = DBA::NULL_DATETIME;
$nofinish = true; $nofinish = true;
} else { } else {
$finish = DateTimeFormat::convert($request['end_time'], 'UTC', DI::apphelper()->getTimeZone()); $finish = DateTimeFormat::convert($request['end_time'], 'UTC', DI::appHelper()->getTimeZone());
$nofinish = false; $nofinish = false;
} }
$start = DateTimeFormat::convert($request['start_time'], 'UTC', DI::apphelper()->getTimeZone()); $start = DateTimeFormat::convert($request['start_time'], 'UTC', DI::appHelper()->getTimeZone());
// create event // create event
$event = []; $event = [];

View file

@ -32,7 +32,7 @@ class Home extends BaseModule
protected function content(array $request = []): string protected function content(array $request = []): string
{ {
$basePath = DI::apphelper()->getBasePath(); $basePath = DI::appHelper()->getBasePath();
$config = DI::config(); $config = DI::config();
// currently no returned data is used // currently no returned data is used

View file

@ -26,7 +26,7 @@ class Acknowledge extends BaseApi
protected function post(array $request = []) protected function post(array $request = [])
{ {
DI::session()->set('oauth_acknowledge', true); DI::session()->set('oauth_acknowledge', true);
DI::apphelper()->redirect(DI::session()->get('return_path')); DI::appHelper()->redirect(DI::session()->get('return_path'));
} }
protected function content(array $request = []): string protected function content(array $request = []): string

View file

@ -60,14 +60,14 @@ class Authorize extends BaseApi
$uid = DI::userSession()->getLocalUserId(); $uid = DI::userSession()->getLocalUserId();
if (empty($uid)) { if (empty($uid)) {
Logger::info('Redirect to login'); Logger::info('Redirect to login');
DI::apphelper()->redirect('login?' . http_build_query(['return_authorize' => $redirect])); DI::appHelper()->redirect('login?' . http_build_query(['return_authorize' => $redirect]));
} else { } else {
Logger::info('Already logged in user', ['uid' => $uid]); Logger::info('Already logged in user', ['uid' => $uid]);
} }
if (!OAuth::existsTokenForUser($application, $uid) && !DI::session()->get('oauth_acknowledge')) { if (!OAuth::existsTokenForUser($application, $uid) && !DI::session()->get('oauth_acknowledge')) {
Logger::info('Redirect to acknowledge'); Logger::info('Redirect to acknowledge');
DI::apphelper()->redirect('oauth/acknowledge?' . http_build_query(['return_authorize' => $redirect, 'application' => $application['name']])); DI::appHelper()->redirect('oauth/acknowledge?' . http_build_query(['return_authorize' => $redirect, 'application' => $application['name']]));
} }
DI::session()->remove('oauth_acknowledge'); DI::session()->remove('oauth_acknowledge');
@ -78,7 +78,7 @@ class Authorize extends BaseApi
} }
if ($application['redirect_uri'] != 'urn:ietf:wg:oauth:2.0:oob') { if ($application['redirect_uri'] != 'urn:ietf:wg:oauth:2.0:oob') {
DI::apphelper()->redirect($request['redirect_uri'] . (strpos($request['redirect_uri'], '?') ? '&' : '?') . http_build_query(['code' => $token['code'], 'state' => $request['state']])); DI::appHelper()->redirect($request['redirect_uri'] . (strpos($request['redirect_uri'], '?') ? '&' : '?') . http_build_query(['code' => $token['code'], 'state' => $request['state']]));
} }
self::$oauth_code = $token['code']; self::$oauth_code = $token['code'];

View file

@ -18,7 +18,7 @@ class RandomProfile extends BaseModule
{ {
protected function content(array $request = []): string protected function content(array $request = []): string
{ {
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
$contact = Contact::getRandomContact(); $contact = Contact::getRandomContact();

View file

@ -109,7 +109,7 @@ class Account extends BaseSettings
} }
if (strlen($timezone) && $timezone != $user['timezone']) { if (strlen($timezone) && $timezone != $user['timezone']) {
DI::apphelper()->setTimeZone($timezone); DI::appHelper()->setTimeZone($timezone);
} }
$fields = [ $fields = [
@ -400,7 +400,7 @@ class Account extends BaseSettings
$expire_network_only = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'network_only', false); $expire_network_only = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'network_only', false);
if (!strlen($user['timezone'])) { if (!strlen($user['timezone'])) {
$timezone = DI::apphelper()->getTimeZone(); $timezone = DI::appHelper()->getTimeZone();
} }
// Set the account type to "Community" when the page is a community page but the account type doesn't fit // Set the account type to "Community" when the page is a community page but the account type doesn't fit

View file

@ -23,7 +23,7 @@ class Profile extends BaseModule
{ {
protected function rawContent(array $request = []) protected function rawContent(array $request = [])
{ {
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
// Ensure we've got a profile owner if updating. // Ensure we've got a profile owner if updating.
$appHelper->setProfileOwner((int)($request['p'] ?? 0)); $appHelper->setProfileOwner((int)($request['p'] ?? 0));

View file

@ -57,7 +57,7 @@ class Thread
return; return;
} }
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
switch ($mode) { switch ($mode) {
case Conversation::MODE_NETWORK: case Conversation::MODE_NETWORK:

View file

@ -192,7 +192,7 @@ class Queue
} }
if (!empty($entry['wid'])) { if (!empty($entry['wid'])) {
$worker = DI::apphelper()->getQueue(); $worker = DI::appHelper()->getQueue();
$wid = $worker['id'] ?? 0; $wid = $worker['id'] ?? 0;
if ($entry['wid'] != $wid) { if ($entry['wid'] != $wid) {
$workerqueue = DBA::selectFirst('workerqueue', ['pid'], ['id' => $entry['wid'], 'done' => false]); $workerqueue = DBA::selectFirst('workerqueue', ['pid'], ['id' => $entry['wid'], 'done' => false]);

View file

@ -1014,7 +1014,7 @@ class Feed
// Display events in the user's timezone // Display events in the user's timezone
if (strlen($owner['timezone'])) { if (strlen($owner['timezone'])) {
DI::apphelper()->setTimeZone($owner['timezone']); DI::appHelper()->setTimeZone($owner['timezone']);
} }
$previous_created = $last_update; $previous_created = $last_update;

View file

@ -114,7 +114,7 @@ class OpenWebAuth
*/ */
public static function init(string $token) public static function init(string $token)
{ {
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
// Clean old OpenWebAuthToken entries. // Clean old OpenWebAuthToken entries.
OpenWebAuthToken::purge('owt', '3 MINUTE'); OpenWebAuthToken::purge('owt', '3 MINUTE');
@ -160,7 +160,7 @@ class OpenWebAuth
*/ */
public static function addVisitorCookieForHandle(string $handle): array public static function addVisitorCookieForHandle(string $handle): array
{ {
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
// Try to find the public contact entry of the visitor. // Try to find the public contact entry of the visitor.
$cid = Contact::getIdForURL($handle); $cid = Contact::getIdForURL($handle);

View file

@ -264,7 +264,7 @@ class Temporal
$input_text, $input_text,
DI::l10n()->t( DI::l10n()->t(
'Time zone: <strong>%s</strong> <a href="%s">Change in Settings</a>', 'Time zone: <strong>%s</strong> <a href="%s">Change in Settings</a>',
str_replace('_', ' ', DI::apphelper()->getTimeZone()) . ' (GMT ' . DateTimeFormat::localNow('P') . ')', str_replace('_', ' ', DI::appHelper()->getTimeZone()) . ' (GMT ' . DateTimeFormat::localNow('P') . ')',
DI::baseUrl() . '/settings' DI::baseUrl() . '/settings'
), ),
$required ? '*' : '', $required ? '*' : '',

View file

@ -21,7 +21,7 @@ class Cron
{ {
public static function execute() public static function execute()
{ {
$basepath = DI::apphelper()->getBasePath(); $basepath = DI::appHelper()->getBasePath();
$last = DI::keyValue()->get('last_cron'); $last = DI::keyValue()->get('last_cron');

View file

@ -19,7 +19,7 @@ class DBUpdate
{ {
// Just in case the last update wasn't failed // Just in case the last update wasn't failed
if (DI::config()->get('system', 'update', Update::SUCCESS) != Update::FAILED) { if (DI::config()->get('system', 'update', Update::SUCCESS) != Update::FAILED) {
Update::run(DI::apphelper()->getBasePath()); Update::run(DI::appHelper()->getBasePath());
} }
} }
} }

View file

@ -21,7 +21,7 @@ class Expire
{ {
public static function execute($param = '', $hook_function = '') public static function execute($param = '', $hook_function = '')
{ {
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
Hook::loadHooks(); Hook::loadHooks();

View file

@ -40,7 +40,7 @@ class FetchMissingActivity
Logger::info('Defer limit reached, activity could not be fetched', ['url' => $url]); Logger::info('Defer limit reached, activity could not be fetched', ['url' => $url]);
// recursively delete all entries that belong to this worker task // recursively delete all entries that belong to this worker task
$queue = DI::apphelper()->getQueue(); $queue = DI::appHelper()->getQueue();
if (!empty($queue['id'])) { if (!empty($queue['id'])) {
Queue::deleteByWorkerId($queue['id']); Queue::deleteByWorkerId($queue['id']);
} }

View file

@ -42,7 +42,7 @@ class Notifier
{ {
public static function execute(string $cmd, int $post_uriid, int $sender_uid = 0) public static function execute(string $cmd, int $post_uriid, int $sender_uid = 0)
{ {
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
Logger::info('Invoked', ['cmd' => $cmd, 'target' => $post_uriid, 'sender_uid' => $sender_uid]); Logger::info('Invoked', ['cmd' => $cmd, 'target' => $post_uriid, 'sender_uid' => $sender_uid]);
@ -414,7 +414,7 @@ class Notifier
*/ */
private static function delivery(string $cmd, int $post_uriid, int $sender_uid, array $target_item, array $parent, array $thr_parent, array $owner, bool $batch_delivery, bool $in_batch, array $contacts, array $ap_contacts, array $conversants = []): int private static function delivery(string $cmd, int $post_uriid, int $sender_uid, array $target_item, array $parent, array $thr_parent, array $owner, bool $batch_delivery, bool $in_batch, array $contacts, array $ap_contacts, array $conversants = []): int
{ {
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
$delivery_queue_count = 0; $delivery_queue_count = 0;
if (!empty($target_item['verb']) && ($target_item['verb'] == Activity::ANNOUNCE)) { if (!empty($target_item['verb']) && ($target_item['verb'] == Activity::ANNOUNCE)) {

View file

@ -30,7 +30,7 @@ class ProfileUpdate {
return; return;
} }
$appHelper = DI::apphelper(); $appHelper = DI::appHelper();
$inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser($uid); $inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser($uid);

View file

@ -29,7 +29,7 @@ require_once 'view/theme/frio/theme.php';
function get_scheme_info($scheme) function get_scheme_info($scheme)
{ {
$theme = DI::apphelper()->getCurrentTheme(); $theme = DI::appHelper()->getCurrentTheme();
$themepath = 'view/theme/' . $theme . '/'; $themepath = 'view/theme/' . $theme . '/';
$scheme = Strings::sanitizeFilePathItem($scheme) ?: FRIO_DEFAULT_SCHEME; $scheme = Strings::sanitizeFilePathItem($scheme) ?: FRIO_DEFAULT_SCHEME;