modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2025-06-23 18:20:46 +04:00
parent 990533a906
commit f23daeb8a8
3 changed files with 24 additions and 5 deletions

View File

@ -269,23 +269,34 @@ abstract class AbstractPageContainer implements IPageContainer {
$this->phase = self::SETUP_PHASE;
if (self::ensure_setupc($page, false, $output)) {
if ($output === false) {
# désactiver la gestion des actions si le retour est false (retour en
# l'état)
$page->dispatchAction(false);
}
$this->overrideSetup($page);
$page->afterSetup();
}
$this->phase = self::PRINT_PHASE;
if ($output instanceof IComponent) {
# composant autonome
self::ensure_phasec($output);
if ($this->beforePrint($output)) {
$this->haveOutput = true;
co::_print([$output]);
}
} elseif (is_callable($output)) {
# générateur de contenu
if ($this->beforePrint(null)) {
$this->haveOutput = true;
$output();
}
} elseif ($output === false) {
# retour en l'état (contenu déjà géré dans setup())
$this->haveOutput = false;
} elseif ($output !== null) {
# contenu json ou texte
if ($this->beforePrint(null)) {
$this->haveOutput = true;
if (is_iterable($output)) {
@ -299,10 +310,11 @@ abstract class AbstractPageContainer implements IPageContainer {
}
echo "]";
} else {
co::_print([strval($output)]);
co::_write([strval($output)]);
}
}
} else {
# afficher la page normalement
$this->overridePrint($page);
}
} catch (Throwable $e) {

View File

@ -4,7 +4,7 @@ namespace nulib\cache;
use Closure;
use IteratorAggregate;
use nulib\cache\CacheChannel;
use nulib\cache\storage_cache;
use nulib\cache\cache;
use nulib\cl;
use nulib\db\CapacitorChannel;
use Traversable;
@ -40,7 +40,7 @@ class CacheDataChannel extends CapacitorChannel implements IteratorAggregate {
}
function getIterator(): Traversable {
$cm = storage_cache::get();
$cm = cache::get();
if ($cm->shouldUpdate($this->cacheIds)) {
$this->capacitor->reset();
foreach (($this->builder)() as $key => $row) {

View File

@ -1,13 +1,20 @@
<?php
namespace nulib\cache;
use nulib\app;
use nulib\cache\CacheChannel;
use nulib\cache\CacheDataChannel;
use nulib\db\Capacitor;
use nulib\db\CapacitorStorage;
use nulib\db\sqlite\SqliteStorage;
class storage_cache {
class cache {
protected static ?string $dbfile = null;
protected static function dbfile(): ?string {
return self::$dbfile ??= app::get()->getVarfile("cache.db");
}
protected static ?CapacitorStorage $storage = null;
static function set_storage(CapacitorStorage $storage): CapacitorStorage {
@ -15,7 +22,7 @@ class storage_cache {
}
protected static function get_storage(): CapacitorStorage {
return self::$storage ??= new SqliteStorage("");
return self::$storage ??= new SqliteStorage(self::dbfile());
}
protected static ?CacheChannel $channel = null;