-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed FormattedDate cast and some refactoring
- Loading branch information
Showing
6 changed files
with
62 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Johncms\Settings; | ||
|
||
use JetBrains\PhpStorm\Pure; | ||
use Johncms\i18n\Translator; | ||
use Johncms\Users\User; | ||
use Psr\Container\ContainerInterface; | ||
|
||
class SiteSettings | ||
{ | ||
protected ?User $user = null; | ||
protected array $config; | ||
protected Translator $translator; | ||
|
||
public function __construct(ContainerInterface $container) | ||
{ | ||
$this->config = $container->get('config')['johncms']; | ||
$this->user = $container->get(User::class); | ||
$this->translator = $container->get(Translator::class); | ||
} | ||
|
||
public function __invoke(): static | ||
{ | ||
return $this; | ||
} | ||
|
||
public function getTimezone(): string | ||
{ | ||
return $this->user?->settings->timezone ?? $this->config['timezone']; | ||
} | ||
|
||
#[Pure] | ||
public function getLanguage(): string | ||
{ | ||
return $this->translator->getLocale(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters