src/SettingsProvider/GeneralSettingsList.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\SettingsProvider;
  3. use App\Entity\GeneralSettings;
  4. use Doctrine\Persistence\ManagerRegistry;
  5. use Symfony\Component\Cache\Adapter\FilesystemAdapter;
  6. use Symfony\Contracts\Cache\ItemInterface;
  7. class GeneralSettingsList
  8. {
  9.     public function __construct(private ManagerRegistry $managerRegistry)
  10.     {
  11.         $this->cache = new FilesystemAdapter;
  12.     }
  13.     public function getWebName(): string
  14.     {
  15.         $item $this->cache->get('settings.webName', function (ItemInterface $item) {
  16.             return $this->generalSettingsDatabase()->getWebsiteName() ?: '';
  17.         });
  18.         return $item ?: '';
  19.     }
  20.     public function getIsRegistration(): bool
  21.     {
  22.         return $this->cache->get('settings.isRegistration', function (ItemInterface $item) {
  23.             return $this->generalSettingsDatabase()->getIsRegistration() ?: true;
  24.         });
  25.     }
  26.     public function getIsMaintenance(): bool
  27.     {
  28.         return $this->cache->get('settings.isMaintenance', function (ItemInterface $item) {
  29.             return $this->generalSettingsDatabase()->getIsMaintenance() ?: false;
  30.         });
  31.     }
  32.     public function getTimeZone(): string
  33.     {
  34.         $item $this->cache->get('settings.timeZone', function (ItemInterface $item) {
  35.             return $this->generalSettingsDatabase()->getWebTimeZone() ?: '';
  36.         });
  37.         return $item ?: '';
  38.     }
  39.     public function getDateFormat(): string
  40.     {
  41.         $item $this->cache->get('settings.dateFormat', function (ItemInterface $item) {
  42.             return $this->generalSettingsDatabase()->getWebDateFormat() ?: '';
  43.         });
  44.         return $item ?: '';
  45.     }
  46.     public function getPrimaryLogo(): string
  47.     {
  48.         $item $this->cache->get('settings.primaryLogo', function (ItemInterface $item) {
  49.             return $this->generalSettingsDatabase()->getPrimaryLogo() ?: '';
  50.         });
  51.         return $item ?: '';
  52.     }
  53.     public function getSecondaryLogo(): string
  54.     {
  55.         $item $this->cache->get('settings.secondaryLogo', function (ItemInterface $item) {
  56.             return $this->generalSettingsDatabase()->getSecondaryLogo() ?: '';
  57.         });
  58.         return $item ?: '';
  59.     }
  60.     public function getLoginBackground(): string
  61.     {
  62.         $item $this->cache->get('settings.loginBgImg', function (ItemInterface $item) {
  63.             return $this->generalSettingsDatabase()->getLoginBackgroundImage() ?: '';
  64.         });
  65.         return $item ?: '';
  66.     }
  67.     public function getFaviconDark(): string
  68.     {
  69.         $item $this->cache->get('settings.faviconDark', function (ItemInterface $item) {
  70.             return $this->generalSettingsDatabase()->getFaviconDark() ?: '';
  71.         });
  72.         return $item ?: '';
  73.     }
  74.     public function getFaviconLight(): string
  75.     {
  76.         $item $this->cache->get('settings.faviconLight', function (ItemInterface $item) {
  77.             return $this->generalSettingsDatabase()->getFaviconLight() ?: '';
  78.         });
  79.         return $item ?: '';
  80.     }
  81.     public function getStartOfWeek(): bool
  82.     {
  83.         return $this->cache->get('settings.startOfWeek', function (ItemInterface $item) {
  84.             return $this->generalSettingsDatabase()->getStartOfWeek() ?: true;
  85.         });
  86.     }
  87.     public function getNumberDecimals(): int
  88.     {
  89.         return $this->cache->get('settings.numberDecimals', function (ItemInterface $item) {
  90.             return $this->generalSettingsDatabase()->getNumberDecimals() ?: 2;
  91.         });
  92.     }
  93.     public function getDecimalSeparator(): string
  94.     {
  95.         $item $this->cache->get('settings.numberDecSep', function (ItemInterface $item) {
  96.             return $this->generalSettingsDatabase()->getNumberDecimalSeparator() ?: '';
  97.         });
  98.         return $item ?: '';
  99.     }
  100.     public function getThousandSeparator(): ?string
  101.     {
  102.         $item $this->cache->get('settings.numberThouSep', function (ItemInterface $item) {
  103.             return $this->generalSettingsDatabase()->getNumberThousandsSeparator() ?: '';
  104.         });
  105.         return $item ?: '';
  106.     }
  107.     public function getTermsCheckbox(): string
  108.     {
  109.         $item $this->cache->get('settings.termsCheckbox', function (ItemInterface $item) {
  110.             return $this->generalSettingsDatabase()->getTermsCheckbox() ?: '';
  111.         });
  112.         return $item ?: '';
  113.     }
  114.     public function getPrivacyCheckbox(): string
  115.     {
  116.         $item $this->cache->get('settings.privacyCheckbox', function (ItemInterface $item) {
  117.             return $this->generalSettingsDatabase()->getPrivacyCheckbox() ?: '';
  118.         });
  119.         return $item ?: '';
  120.     }
  121.     public function getTermsText(): string
  122.     {
  123.         $item $this->cache->get('settings.termsText', function (ItemInterface $item) {
  124.             return $this->generalSettingsDatabase()->getTermsText() ?: '';
  125.         });
  126.         return $item ?: '';
  127.     }
  128.     public function getPrivacyText(): string
  129.     {
  130.         $item $this->cache->get('settings.privacyText', function (ItemInterface $item) {
  131.             return $this->generalSettingsDatabase()->getPrivacyText() ?: '';
  132.         });
  133.         return $item ?: '';
  134.     }
  135.     public function getFileUploadLimit(): string
  136.     {
  137.         $item $this->cache->get('settings.fileUploadLimit', function (ItemInterface $item) {
  138.             return $this->generalSettingsDatabase()->getFileUploadLimit() ?: '1';
  139.         });
  140.         return $item ?: '';
  141.     }
  142.     private function generalSettingsDatabase(): GeneralSettings
  143.     {
  144.         return $this->managerRegistry->getRepository(GeneralSettings::class)->findOneBy([]);
  145.     }
  146. }