diff --git a/nur_src/cli/Application.php b/nur_src/cli/Application.php index 67069cd..e3051d4 100644 --- a/nur_src/cli/Application.php +++ b/nur_src/cli/Application.php @@ -71,6 +71,9 @@ abstract class Application { */ const USE_RUNLOCK = false; + /** @var bool faut-il installer le gestionnaire de signaux? */ + const USE_SIGNAL_HANDLER = false; + protected static function _app_init(): void { config::set_fact(config::FACT_CLI_APP); @@ -137,10 +140,26 @@ abstract class Application { static function run(?Application $app=null): void { $unlock = false; $stop = false; - register_shutdown_function(function () use (&$unlock, &$stop) { - if ($unlock) app::get()->getRunfile()->release(); - if ($stop) app::get()->getRunfile()->wfStop(); - }); + $shutdownHandler = function () use (&$unlock, &$stop) { + if ($unlock) { + app::get()->getRunfile()->release(); + $unlock = false; + } + if ($stop) { + app::get()->getRunfile()->wfStop(); + $stop = false; + } + }; + register_shutdown_function($shutdownHandler); + if (static::USE_SIGNAL_HANDLER) { + $signalHandler = function(int $signo, $siginfo) { + self::exit(255); + }; + pcntl_signal(SIGHUP, $signalHandler); + pcntl_signal(SIGINT, $signalHandler); + pcntl_signal(SIGQUIT, $signalHandler); + pcntl_signal(SIGTERM, $signalHandler); + } try { static::_app_init(); if (static::USE_RUNFILE) { diff --git a/nur_src/v/bs3/vc/CListGroup.php b/nur_src/v/bs3/vc/CListGroup.php index 86a9456..775b7c8 100644 --- a/nur_src/v/bs3/vc/CListGroup.php +++ b/nur_src/v/bs3/vc/CListGroup.php @@ -3,6 +3,7 @@ namespace nur\v\bs3\vc; use nur\b\params\Tparametrable; use nur\b\ValueException; +use nur\func; use nur\v\vo; /** @@ -14,7 +15,9 @@ class CListGroup extends _CItemList { const CONTAINER = null; const PARAMETRABLE_PARAMS_SCHEMA = [ + "list_group_class" => ["?array", null, "classe CSS de la liste"], "container" => ["string", "ul", "container de la liste: ul ou div"], + "item_func" => ["?callable", null, "fonction avec la signature (\$vs, \$item) retournant l'élément à afficher"], ]; function __construct(?iterable $items=null, ?array $params=null) { @@ -24,6 +27,8 @@ class CListGroup extends _CItemList { parent::__construct($items, $params); } + protected $ppListGroupClass; + private $ctag, $itag; function pp_setContainer(string $container): self { @@ -42,6 +47,14 @@ class CListGroup extends _CItemList { return $this; } + /** @var array */ + protected $itemCtx; + + function pp_setItemFunc($itemFunc): void { + if ($itemFunc === null) $this->itemCtx = null; + else $this->itemCtx = func::_prepare($itemFunc); + } + /** retourner le contenu associé au conteneur */ function container(): ?array { return null; @@ -49,7 +62,7 @@ class CListGroup extends _CItemList { protected function _printStartContainer($container): void { vo::start($this->ctag, [ - "class" => "list-group", + "class" => ["list-group", $this->ppListGroupClass], $this->container(), ]); } @@ -64,7 +77,11 @@ class CListGroup extends _CItemList { /** retourner le contenu associé à l'élément spécifié. */ function item($item): ?iterable { - return [$item]; + $vs = [$item]; + if ($this->itemCtx !== null) { + $vs = func::_call($this->itemCtx, [$vs, $item]); + } + return $vs; } protected function _printStartItem(): void { diff --git a/nur_src/v/plugins/autorefreshPlugin.php b/nur_src/v/plugins/autorefreshPlugin.php index fb84c70..1c357a0 100644 --- a/nur_src/v/plugins/autorefreshPlugin.php +++ b/nur_src/v/plugins/autorefreshPlugin.php @@ -30,7 +30,11 @@ class autorefreshPlugin extends BasePlugin {