ver. 0.278: Settings + Languages frontend migration, bug fix get_single_settings_value
- Add cached frontend methods to existing Domain repositories (allSettings, getSingleValue, defaultLanguage, activeLanguages, translations) - Convert front\factory\Settings and Languages to facades delegating to Domain repositories - Fix get_single_settings_value() - was hardcoded to 'firm_name', now uses $param correctly - Add CacheHandler stub methods (get/set/exists) to test bootstrap - Establish architectural rule: Domain classes are shared between admin and frontend Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
namespace Domain\Settings;
|
||||
|
||||
/**
|
||||
* Repozytorium ustawien panelu administratora.
|
||||
* Repozytorium ustawien — wspolne dla admin i frontendu.
|
||||
*/
|
||||
class SettingsRepository
|
||||
{
|
||||
@@ -141,6 +141,58 @@ class SettingsRepository
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobranie wszystkich ustawien z cache Redis.
|
||||
*
|
||||
* @param bool $skipCache Pomija cache (np. przy generowaniu htaccess)
|
||||
*/
|
||||
public function allSettings(bool $skipCache = false): array
|
||||
{
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheKey = 'Domain\Settings\SettingsRepository::allSettings';
|
||||
|
||||
if (!$skipCache) {
|
||||
$objectData = $cacheHandler->get($cacheKey);
|
||||
if ($objectData) {
|
||||
return unserialize($objectData);
|
||||
}
|
||||
}
|
||||
|
||||
$results = $this->db->select('pp_settings', '*');
|
||||
$settings = [];
|
||||
|
||||
if (is_array($results)) {
|
||||
foreach ($results as $row) {
|
||||
$settings[$row['param']] = $row['value'];
|
||||
}
|
||||
}
|
||||
|
||||
$cacheHandler->set($cacheKey, $settings);
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobranie pojedynczej wartosci ustawienia po nazwie parametru.
|
||||
*/
|
||||
public function getSingleValue(string $param): string
|
||||
{
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheKey = "Domain\Settings\SettingsRepository::getSingleValue:$param";
|
||||
|
||||
$objectData = $cacheHandler->get($cacheKey);
|
||||
if ($objectData) {
|
||||
return unserialize($objectData);
|
||||
}
|
||||
|
||||
$value = $this->db->get('pp_settings', 'value', ['param' => $param]);
|
||||
$value = (string)($value ?? '');
|
||||
|
||||
$cacheHandler->set($cacheKey, $value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function isEnabled($value): bool
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
|
||||
Reference in New Issue
Block a user