mirror of
https://github.com/friendica/friendica
synced 2025-01-22 13:39:47 +00:00
Create AppHelper class
This commit is contained in:
parent
d29a18e56f
commit
81b0bab084
2 changed files with 54 additions and 0 deletions
49
src/AppHelper.php
Normal file
49
src/AppHelper.php
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Copyright (C) 2010-2024, the Friendica project
|
||||||
|
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
namespace Friendica;
|
||||||
|
|
||||||
|
use DateTimeZone;
|
||||||
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper for our main application structure for the life of this page.
|
||||||
|
*
|
||||||
|
* Primarily deals with the URL that got us here
|
||||||
|
* and tries to make some sense of it, and
|
||||||
|
* stores our page contents and config storage
|
||||||
|
* and anything else that might need to be passed around
|
||||||
|
* before we spit the page out.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
final class AppHelper
|
||||||
|
{
|
||||||
|
private $timezone = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the timezone
|
||||||
|
*
|
||||||
|
* @param string $timezone A valid time zone identifier, see https://www.php.net/manual/en/timezones.php
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setTimeZone(string $timezone)
|
||||||
|
{
|
||||||
|
$this->timezone = (new DateTimeZone($timezone))->getName();
|
||||||
|
|
||||||
|
DateTimeFormat::setLocalTimeZone($this->timezone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the timezone
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getTimeZone(): string
|
||||||
|
{
|
||||||
|
return $this->timezone;
|
||||||
|
}
|
||||||
|
}
|
|
@ -78,6 +78,11 @@ abstract class DI
|
||||||
return self::$dice->create(App::class);
|
return self::$dice->create(App::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function apphelper(): AppHelper
|
||||||
|
{
|
||||||
|
return self::$dice->create(AppHelper::class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Database\Database
|
* @return Database\Database
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue