Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ArchivesCell | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| display | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | |
| 4 | namespace DefaultTheme\View\Cell; |
| 5 | |
| 6 | use Cake\View\Cell; |
| 7 | |
| 8 | /** |
| 9 | * Archives cell |
| 10 | * |
| 11 | * Displays article archives organized by year and month |
| 12 | */ |
| 13 | class ArchivesCell extends Cell |
| 14 | { |
| 15 | /** |
| 16 | * List of valid options that can be passed into this |
| 17 | * cell's constructor. |
| 18 | * |
| 19 | * @var array<string> |
| 20 | */ |
| 21 | protected array $_validCellOptions = ['cacheKey']; |
| 22 | |
| 23 | /** |
| 24 | * Default display method |
| 25 | * |
| 26 | * Fetches and displays article archive dates |
| 27 | * |
| 28 | * @param string|null $cacheKey Optional cache key for performance |
| 29 | * @return void |
| 30 | */ |
| 31 | public function display(?string $cacheKey = null): void |
| 32 | { |
| 33 | $articlesTable = $this->fetchTable('Articles'); |
| 34 | |
| 35 | // Generate cache key if not provided |
| 36 | if ($cacheKey === null) { |
| 37 | $lang = $this->request->getParam('lang', 'en'); |
| 38 | $cacheKey = 'archives_' . $lang . '_'; |
| 39 | } |
| 40 | |
| 41 | $articleArchives = $articlesTable->getArchiveDates($cacheKey); |
| 42 | |
| 43 | $this->set('articleArchives', $articleArchives); |
| 44 | } |
| 45 | } |