nur-sery/nur_src/mapper/base/mappers_command.php

73 lines
2.0 KiB
PHP

<?php
namespace nur\mapper\base;
use nur\cli\DynamicCommand;
use nur\mapper\csv\Assoc2CsvMapper_command;
use nur\mapper\csv\Csv2AssocMapper_command;
use nur\mapper\fsv\Assoc2FsvMapper_command;
use nur\mapper\fsv\Fsv2AssocMapper_command;
use nur\mapper\item\Assoc2SeqMapper_command;
use nur\mapper\item\AttributeFilterMapper_command;
use nur\mapper\item\GenericMapper_command;
use nur\mapper\item\ItemFilterMapper_command;
use nur\mapper\item\NumberMapper_command;
use nur\mapper\item\SchemaMapper_command;
use nur\mapper\item\Seq2AssocMapper_command;
use nur\mapper\item\StreamMapper_command;
use nur\mapper\item\StringMapper_command;
use nur\mapper\item\TextMapper_command;
use nur\mapper\line\IconvMapper_command;
/**
* Class mappers_command: classe de support pour construire un ensemble de
* mappers pour une application recevant des commandes utilisateurs
*/
class mappers_command extends DynamicCommand {
const PRODUCER_CLASSES = [
];
const CONSUMER_CLASSES = [
];
const MAPPER_CLASSES = [
# base
FuncMapper_command::class,
# item
StreamMapper_command::class,
StringMapper_command::class,
TextMapper_command::class,
NumberMapper_command::class,
GenericMapper_command::class,
Seq2AssocMapper_command::class,
SchemaMapper_command::class,
ItemFilterMapper_command::class,
AttributeFilterMapper_command::class,
Assoc2SeqMapper_command::class,
# line
IconvMapper_command::class,
# csv
Csv2AssocMapper_command::class,
Assoc2CsvMapper_command::class,
# fsv
Fsv2AssocMapper_command::class,
Assoc2FsvMapper_command::class,
];
protected function DYNAMIC_COMMAND_CLASSES(): array {
return array_merge(self::PRODUCER_CLASSES, self::CONSUMER_CLASSES, self::MAPPER_CLASSES);
}
function COMMANDS(): array {
$commands = [];
foreach ($this->DYNAMIC_COMMAND_CLASSES() as $cc) {
$commands[] = $cc::get_def();
}
return $commands;
}
static $mappers = [];
static function add(Mapper $mapper): Mapper {
self::$mappers[] = $mapper;
return $mapper;
}
}