modifs.mineures sans commentaires
This commit is contained in:
parent
944daa8ea4
commit
9b83f276fe
@ -162,7 +162,7 @@ abstract class Application {
|
|||||||
return $page;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensurePhase(IPage $page, int $phase, bool $after=false, &$output=null) {
|
protected function ensurePhase(IPage $page, int $phase, bool $after=false, &$output=null) {
|
||||||
if (!$page->didComponentPhase($phase)) {
|
if (!$page->didComponentPhase($phase)) {
|
||||||
if ($page->beforeComponentPhase($phase)) {
|
if ($page->beforeComponentPhase($phase)) {
|
||||||
page::set_component_phase($phase);
|
page::set_component_phase($phase);
|
||||||
|
|||||||
@ -6,10 +6,10 @@ use nulib\web\model\IComponent;
|
|||||||
abstract class AbstractComponent implements IComponent {
|
abstract class AbstractComponent implements IComponent {
|
||||||
use TComponentPhase;
|
use TComponentPhase;
|
||||||
|
|
||||||
const COMPONENT_CAN_PREPARE = false;
|
const COMPONENT_PHASE_CAN_PREPARE = false;
|
||||||
const COMPONENT_CAN_CONFIGURE = false;
|
const COMPONENT_PHASE_CAN_CONFIGURE = false;
|
||||||
const COMPONENT_CAN_SETUP = false;
|
const COMPONENT_PHASE_CAN_SETUP = false;
|
||||||
const COMPONENT_CAN_TEARDOWN = false;
|
const COMPONENT_PHASE_CAN_TEARDOWN = false;
|
||||||
|
|
||||||
function RENDERER_CLASS(): ?string {
|
function RENDERER_CLASS(): ?string {
|
||||||
return static::RENDERER_CLASS;
|
return static::RENDERER_CLASS;
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace nulib\web\base;
|
namespace nulib\web\base;
|
||||||
|
|
||||||
use nulib\web\model\IComponent;
|
use nulib\php\content\c;
|
||||||
|
use nulib\php\content\IContent;
|
||||||
|
use nulib\php\content\IPrintable;
|
||||||
use nulib\web\model\IRenderer;
|
use nulib\web\model\IRenderer;
|
||||||
|
|
||||||
class HtmlRenderer implements IRenderer {
|
class HtmlRenderer implements IRenderer {
|
||||||
function render($data): void {
|
function render($data): void {
|
||||||
header("Content-Type: text/html; charset=utf-8");
|
header("Content-Type: text/html; charset=utf-8");
|
||||||
if ($data instanceof IComponent) {
|
if ($data instanceof IPrintable || $data instanceof IContent) {
|
||||||
$data->print();
|
c::write([$data]);
|
||||||
} else {
|
} else {
|
||||||
echo $data;
|
echo $data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,15 +14,15 @@ trait TComponentPhase {
|
|||||||
$this->currentComponentPhase = $phase;
|
$this->currentComponentPhase = $phase;
|
||||||
switch ($phase) {
|
switch ($phase) {
|
||||||
case page::PHASE_PREPARE:
|
case page::PHASE_PREPARE:
|
||||||
if (static::COMPONENT_CAN_PREPARE) $this->prepare();
|
if (static::COMPONENT_PHASE_CAN_PREPARE) $this->doComponentPhasePrepare();
|
||||||
break;
|
break;
|
||||||
case page::PHASE_CONFIGURE:
|
case page::PHASE_CONFIGURE:
|
||||||
if (static::COMPONENT_CAN_CONFIGURE) $this->configure();
|
if (static::COMPONENT_PHASE_CAN_CONFIGURE) $this->doComponentPhaseConfigure();
|
||||||
break;
|
break;
|
||||||
case page::PHASE_SETUP:
|
case page::PHASE_SETUP:
|
||||||
if (static::COMPONENT_CAN_SETUP) return $this->setup();
|
if (static::COMPONENT_PHASE_CAN_SETUP) return $this->doComponentPhaseSetup();
|
||||||
case page::PHASE_TEARDOWN:
|
case page::PHASE_TEARDOWN:
|
||||||
if (static::COMPONENT_CAN_TEARDOWN) $this->teardown();
|
if (static::COMPONENT_PHASE_CAN_TEARDOWN) $this->doComponentPhaseTeardown();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace nulib\web\model;
|
namespace nulib\web\model;
|
||||||
|
|
||||||
interface IComponent {
|
use nulib\php\content\IContent;
|
||||||
|
|
||||||
|
interface IComponent extends IContent {
|
||||||
/** retourner la classe de renderer à utiliser pour afficher ce composant */
|
/** retourner la classe de renderer à utiliser pour afficher ce composant */
|
||||||
function RENDERER_CLASS(): ?string;
|
function RENDERER_CLASS(): ?string;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace nulib\web\model;
|
namespace nulib\web\model;
|
||||||
|
|
||||||
interface IPage extends IComponent {
|
use nulib\php\content\IPrintable;
|
||||||
|
|
||||||
|
interface IPage extends IComponent, IPrintable {
|
||||||
/** indiquer si cette page a besoin d'avoir une session valide */
|
/** indiquer si cette page a besoin d'avoir une session valide */
|
||||||
function USE_SESSION(): bool;
|
function USE_SESSION(): bool;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user