nur-sery/nur_src/mapper/item/GenericMapper_command.php

41 lines
1.1 KiB
PHP

<?php
namespace nur\mapper\item;
use nur\mapper\base\Mapper;
use nur\mapper\base\mappers_command;
use nur\mapper\base\Tparams_command;
/**
* Class GenericMapper_command: classe de support pour construire une instance
* de mapper pour une application recevant des commandes utilisateurs
*/
class GenericMapper_command {
use Tparams_command;
static function get_def(): array {
return [null, [
"package\\Mapper",
"help" => "appliquer un mapper générique",
], function(string $command): ?array {
if (!is_subclass_of($command, Mapper::class)) return null;
return [$command, "help" => "appliquer le mapper $command",
"action" => [static::class, "create_command"],
"cmd_args" => [
"usage" => $command,
["-o", "--param", "args" => "value",
"action" => [static::class, "add_params"],
"help" => "spécifier une option générique",
],
],
];
}];
}
/** @var Mapper */
protected static $command;
static function create_command($value, $name, $arg) {
self::$command = mappers_command::add(new $arg());
}
}