<?php
namespace App\SettingsProvider;
use App\Entity\GeneralSettings;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Contracts\Cache\ItemInterface;
class GeneralSettingsList
{
public function __construct(private ManagerRegistry $managerRegistry)
{
$this->cache = new FilesystemAdapter;
}
public function getWebName(): string
{
$item = $this->cache->get('settings.webName', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getWebsiteName() ?: '';
});
return $item ?: '';
}
public function getIsRegistration(): bool
{
return $this->cache->get('settings.isRegistration', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getIsRegistration() ?: true;
});
}
public function getIsMaintenance(): bool
{
return $this->cache->get('settings.isMaintenance', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getIsMaintenance() ?: false;
});
}
public function getTimeZone(): string
{
$item = $this->cache->get('settings.timeZone', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getWebTimeZone() ?: '';
});
return $item ?: '';
}
public function getDateFormat(): string
{
$item = $this->cache->get('settings.dateFormat', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getWebDateFormat() ?: '';
});
return $item ?: '';
}
public function getPrimaryLogo(): string
{
$item = $this->cache->get('settings.primaryLogo', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getPrimaryLogo() ?: '';
});
return $item ?: '';
}
public function getSecondaryLogo(): string
{
$item = $this->cache->get('settings.secondaryLogo', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getSecondaryLogo() ?: '';
});
return $item ?: '';
}
public function getLoginBackground(): string
{
$item = $this->cache->get('settings.loginBgImg', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getLoginBackgroundImage() ?: '';
});
return $item ?: '';
}
public function getFaviconDark(): string
{
$item = $this->cache->get('settings.faviconDark', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getFaviconDark() ?: '';
});
return $item ?: '';
}
public function getFaviconLight(): string
{
$item = $this->cache->get('settings.faviconLight', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getFaviconLight() ?: '';
});
return $item ?: '';
}
public function getStartOfWeek(): bool
{
return $this->cache->get('settings.startOfWeek', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getStartOfWeek() ?: true;
});
}
public function getNumberDecimals(): int
{
return $this->cache->get('settings.numberDecimals', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getNumberDecimals() ?: 2;
});
}
public function getDecimalSeparator(): string
{
$item = $this->cache->get('settings.numberDecSep', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getNumberDecimalSeparator() ?: '';
});
return $item ?: '';
}
public function getThousandSeparator(): ?string
{
$item = $this->cache->get('settings.numberThouSep', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getNumberThousandsSeparator() ?: '';
});
return $item ?: '';
}
public function getTermsCheckbox(): string
{
$item = $this->cache->get('settings.termsCheckbox', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getTermsCheckbox() ?: '';
});
return $item ?: '';
}
public function getPrivacyCheckbox(): string
{
$item = $this->cache->get('settings.privacyCheckbox', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getPrivacyCheckbox() ?: '';
});
return $item ?: '';
}
public function getTermsText(): string
{
$item = $this->cache->get('settings.termsText', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getTermsText() ?: '';
});
return $item ?: '';
}
public function getPrivacyText(): string
{
$item = $this->cache->get('settings.privacyText', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getPrivacyText() ?: '';
});
return $item ?: '';
}
public function getFileUploadLimit(): string
{
$item = $this->cache->get('settings.fileUploadLimit', function (ItemInterface $item) {
return $this->generalSettingsDatabase()->getFileUploadLimit() ?: '1';
});
return $item ?: '';
}
private function generalSettingsDatabase(): GeneralSettings
{
return $this->managerRegistry->getRepository(GeneralSettings::class)->findOneBy([]);
}
}