fix cache
This commit is contained in:
parent
d1b7ca404d
commit
441323e0f5
7 changed files with 16 additions and 17 deletions
|
|
@ -3,20 +3,20 @@
|
|||
use adrienpayet\notifications\NotificationsPage;
|
||||
|
||||
class ProjectPage extends NotificationsPage {
|
||||
public function getStepsFromCache() {
|
||||
public function getSteps() {
|
||||
$apiCache = kirby()->cache('api');
|
||||
$stepsData = $apiCache->get($this->slug() . '_' . 'steps');
|
||||
$stepsData = $apiCache?->get($this->slug() . '_' . 'steps');
|
||||
|
||||
if ($stepsData === null) {
|
||||
$steps = $this->getRefreshedSteps(true);
|
||||
|
||||
refreshProjectStepsCache($this, $steps);
|
||||
return $steps;
|
||||
if ($stepsData === null || count($stepsData) > 0) {
|
||||
$this->rebuildStepsCache();
|
||||
};
|
||||
|
||||
$stepsData = $apiCache->get($this->slug() . '_' . 'steps');
|
||||
|
||||
return $stepsData;
|
||||
}
|
||||
public function getRefreshedSteps() {
|
||||
|
||||
public function rebuildStepsCache() {
|
||||
// Create steps
|
||||
$steps = [];
|
||||
foreach ($this->children() as $child) {
|
||||
|
|
@ -29,8 +29,9 @@ class ProjectPage extends NotificationsPage {
|
|||
|
||||
// Sort steps by their index
|
||||
usort($steps, fn($a, $b) => $a['index'] <=> $b['index']);
|
||||
|
||||
return $steps;
|
||||
|
||||
$apiCache = kirby()->cache('api');
|
||||
$apiCache->set($this->slug() . '_' . 'steps', $steps);
|
||||
}
|
||||
|
||||
private function createStep($child) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue