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

View File

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

View File

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