Add new settings and cache repository files, update admin settings controller and templates

- Introduced new `SettingsRepository` and `CacheRepository` classes in the `autoload\Domain` namespace.
- Updated `SettingsController` in the `admin\Controllers` namespace to enhance settings management.
- Added new templates for settings in `admin\templates\settings` and `admin\templates\site`.
- Improved overall structure and organization of settings-related files.
This commit is contained in:
2026-02-05 23:32:48 +01:00
parent 3a7be21432
commit 1c88f8adfa
35 changed files with 1233 additions and 87 deletions

View File

@@ -183,14 +183,32 @@ $product = \shop\Product::getFromCache($product_id, $lang_id, $permutation_hash)
### Nowa struktura (w trakcie migracji)
```
autoload/
├── Domain/ # Nowa warstwa biznesowa
── Product/
└── ProductRepository.php
├── shop/ # Legacy - fasady do nowych klas
├── admin/factory/ # Legacy - stopniowo migrowane
└── front/factory/ # Legacy - stopniowo migrowane
├── Domain/ # Nowa warstwa biznesowa (namespace \Domain\)
── Product/
└── ProductRepository.php # getQuantity, getPrice, getName, find, updateQuantity
│ ├── Banner/
│ │ └── BannerRepository.php # find, delete, save
│ ├── Settings/
│ │ └── SettingsRepository.php # saveSettings, getSettings (fasada → factory)
│ └── Cache/
│ └── CacheRepository.php # clearCache (dirs + Redis)
├── admin/
│ ├── Controllers/ # Nowe kontrolery (namespace \admin\Controllers\)
│ │ ├── BannerController.php # DI, instancyjny
│ │ └── SettingsController.php # DI, instancyjny (clearCache, save, view)
│ ├── class.Site.php # Router: nowy kontroler → fallback stary
│ ├── controls/ # Stare kontrolery (niezależny fallback)
│ ├── factory/ # Stare helpery (niezależny fallback)
│ └── view/ # Widoki (statyczne - bez zmian)
├── shop/ # Legacy - fasady do Domain
└── front/factory/ # Legacy - stopniowo migrowane
```
### Routing admin (admin\Site::route())
1. Sprawdź mapę `$newControllers` → utwórz instancję z DI → wywołaj
2. Jeśli nowy kontroler nie istnieje (`class_exists()` = false) → fallback na `admin\controls\`
3. Stary kontroler jest NIEZALEŻNY od nowych klas (bezpieczny fallback)
### Dependency Injection
Nowe klasy używają **Dependency Injection** zamiast `global` variables:
```php
@@ -215,13 +233,39 @@ $quantity = $repository->getQuantity($id);
### Struktura
```
tests/
├── Unit/ # Testy jednostkowe
── Domain/Product/ProductRepositoryTest.php
└── Integration/ # Testy integracyjne
├── Unit/
── Domain/
│ │ ├── Product/ProductRepositoryTest.php # 11 testów
│ │ ├── Banner/BannerRepositoryTest.php # 4 testy
│ │ ├── Settings/SettingsRepositoryTest.php # 3 testy
│ │ └── Cache/CacheRepositoryTest.php # 4 testy
│ └── admin/
│ └── Controllers/SettingsControllerTest.php # 7 testów
└── Integration/
```
**Łącznie: 29 testów, 60 asercji**
## Ostatnie modyfikacje
### 2026-02-05: Migracja Settings + Cache (ver. 0.240)
- **NOWE:** `Domain\Settings\SettingsRepository` - repozytorium ustawień (fasada → factory)
- **NOWE:** `Domain\Cache\CacheRepository` - repozytorium cache (dirs + Redis)
- **NOWE:** `admin\Controllers\SettingsController` - kontroler z DI (clearCache, save, view)
- **FIX:** Brakujący `id="content"` w main-layout.php (komunikaty grid.js)
- **FIX:** `persist_edit = true` w settings.php (komunikat po zapisie)
- Stary kontroler `admin\controls\Settings` zachowany jako fallback
- Testy: 29 testów, 60 asercji (+14 nowych)
- Bootstrap testów: stuby klas systemowych (S, RedisConnection, Redis, CacheHandler)
### 2026-02-05: Migracja Banner + Product (ver. 0.239)
- **NOWE:** `Domain\Banner\BannerRepository` - repozytorium banerów (find, delete, save)
- **NOWE:** `admin\Controllers\BannerController` - pierwszy kontroler z DI
- **NOWE:** Router z mapą `$newControllers` + fallback na stare kontrolery
- **NOWE:** Autoloader PSR-4 fallback w 9 entry pointach
- Zmigrowano: `get_product_price()``ProductRepository::getPrice()`
- Zmigrowano: `get_product_name()``ProductRepository::getName()`
- Testy: 15 testów, 31 asercji
### 2025-02-05: Refaktoryzacja - Product Repository (ver. 0.238)
- **NOWE:** `Domain\Product\ProductRepository` - pierwsza klasa w nowej architekturze
- **NOWE:** Dependency Injection zamiast `global $mdb`
@@ -236,4 +280,4 @@ tests/
- Metoda `clear_product_cache()` w klasie S
---
*Dokument aktualizowany: 2025-02-05*
*Dokument aktualizowany: 2026-02-05*