Index

ImportSocket

MMO\core · 1 symbol · generated 5 Oct 2026

class

ImportSocket

ImportSocket.php:29

Import data using a socket.

class MMO\core\ImportSocket extends MMO\core\classes\aModule
Namespace
MMO\core
Extends
aModule
Socket available commands: - `list`: list all configurations available. return: `>list:{json}` where `{json}` is an array of configuration's name encoded in json. - `config:{name}`: select the configuration `{name}` return: none - `keys`: only use these keys from the config - `data`: set the data to import - `run`: run the importer - `stop`: stop the importer - `exit`: close the importer and its socket

Index

REQUEST_COMMAND
REQUEST_DATA
configListmap of configuration {name: config} if config is a string, it is a json file
exitCheck
importercurrent importer
importerscurrent importers
mainScript
url
websocket
addConfig($config, $name)Add a configuration to the list of available configurations.
addImporter($importer, $name)Register one importer directly (on top of, or instead of, setImporters).
canRun()
DefaultConfig() static
getConfigList()
getCurrentImporter()
getImporters()
getWebsocket()Lazily open the websocket (Websocket::Setup) on first call, memoizing the result (including failure --
ignore($row, $key)Ignore one entity for the current row (Importer::ignore), logging it to the websocket first.
pairImporters($filter, $data)Which importer reads which entry of the data: each importer paired with the data key it imports.
readConfig($name)Get/Read the configuration from configList
run($data, $config)
setConfigList($configList)Set a list of usable configurations for the importer
setImporters($config)Set the importer configuration
write($data, $mode)
__destruct()Closes the websocket, if one was ever opened (getWebsocket).

Constants2

REQUEST_COMMAND

const REQUEST_COMMAND = ''

REQUEST_DATA

const REQUEST_DATA = ''

Properties7

configList

map of configuration {name: config} if config is a string, it is a json file

#[MMO\core\attributes\Serialize(unserialize: 'setConfigs')] protected array $configList = []
Type
array

exitCheck

int $exitCheck = 5
Type
int

importer

current importer

#[MMO\core\attributes\Serialize(false)] protected ?MMO\core\entities\Importer $importer = null
Type
null | Importer

importers

current importers

#[MMO\core\attributes\Serialize(false)] protected ?array $importers = []
Type
null | array

mainScript

string|int $mainScript = 3
Type
string | int

websocket

#[MMO\core\attributes\Serialize(false)] protected MMO\core\server\Websocket|false|null $websocket
Type
Websocket | false | null

Methods16

addConfig($config, $name)

ImportSocket.php:122

Add a configuration to the list of available configurations.

function addConfig(array|string $config, ?string $name = null): void
$configarray | stringif string, MUST represents a json file or a folder containing json files
$name = nullnull | stringthe name to use to refer to this configuration
returnsvoid

addImporter($importer, $name)

ImportSocket.php:168

Register one importer directly (on top of, or instead of, setImporters).

function addImporter(MMO\core\entities\Importer $importer, ?string $name = null): void
$importerImporter
$name = nullnull | stringif null, appended positionally (making $importers a plain list).
returnsvoid

canRun()

ImportSocket.php:93
function canRun(): bool
returnsboolwhether run can actually be used here (i.e. a websocket could be opened -- requires the command line).

DefaultConfig()

staticImportSocket.php:61
static function DefaultConfig(): array
returnsarraydefault configuration: $url defaults to a local websocket on port 55555.

getConfigList()

ImportSocket.php:100
function getConfigList(): array
returnsarrayname => configuration (a string is a path to a JSON file/folder, an array is an inline configuration).

getCurrentImporter()

ImportSocket.php:179
function getCurrentImporter(): ?MMO\core\entities\Importer
returnsnull | Importerthe importer run is currently executing, or null when idle.

getWebsocket()

ImportSocket.php:85

Lazily open the websocket (Websocket::Setup) on first call, memoizing the result (including failure --

function getWebsocket(): ?MMO\core\server\Websocket
See
$websocket can be false, meaning "already tried, not usable here", vs. unset, meaning "not tried yet").
returnsnull | Websocketnull if not running on the command line (Websocket::Setup's own CLI requirement).

pairImporters($filter, $data)

ImportSocket.php:260

Which importer reads which entry of the data: each importer paired with the data key it imports.

protected function pairImporters(?array $filter, ArrayAccess|array|null $data): arrayNamed importers read the entry of the same name. Unnamed ones (a list) read the data's entries in order: the importer at index `i` reads the data's `i`-th key, and an importer past the data's last key reads nothing. `$filter` (the `keys` command) keeps only the importers whose key it lists. NOTE: both of these used to share one `$keys` variable: with unnamed importers and named data keys, the data's keys were then used as the importer filter, no importer matched, and a run silently imported nothing.
$filternull | arrayimporter keys to run, null for all
$dataArrayAccess | array | null
returnsarrayint|string, 1: mixed}> [data key, importer], in importer order
//importers [$users, $orders], data ['users' => [...], 'orders' => [...]] $this->pairImporters(null, $data); // [['users', $users], ['orders', $orders]]

setConfigList($configList)

ImportSocket.php:109

Set a list of usable configurations for the importer

function setConfigList(array $configList): void
$configListarray{name: multiple configuration}
returnsvoid

setImporters($config)

ImportSocket.php:159

Set the importer configuration

function setImporters(array|string|int $config): void
$configarray | string | intif int, look for the nth config in configList if string, look for the config with that name in configList if array, set directly this as the configuration. It MUST be a multiple configuration as described in the Importer.
returnsvoid
Inherited members (47)
ConstantsDeclared byDescription
ALERTiLogLevelAlert: Action must be taken immediately.
ALLiLogLevelMask for all
ALL_PLUSiLogLeveldebug everything
BACKTRACEiLogLevel
CRITICALiLogLevelCritical: Critical conditions.
DEBUGiLogLevelDebug: Detailed debug information.
DEEPiLogLeveldebug everything with arguments
EMERGENCYiLogLevelEmergency: System is unusable.
ERRORiLogLevelError: Runtime errors that do not require immediate action but should typically be logged and monitored.
ERROR_PLUSiLogLevelMask for all error
FATALiLogLevelMask for all fatal error
INFOiLogLevelInfo: Interesting events.
INFO_PLUSiLogLevelMask for all errors/warning/notices/info
MEMORYiLogLevelinclude backtrace object
NOTICEiLogLevelNotice: Normal but significant events.
NOTICE_PLUSiLogLevelMask for all errors/warning/notices/info
TRACEiLogLevelinclude backtrace as origins
WARNINGiLogLevelWarning: Exceptional occurrences that are not errors.
WARNING_PLUSiLogLevelMask for all errors and warnings
PropertiesDeclared byDescription
verbosityaModule
MethodsDeclared byDescription
alert($message, $context)aModuleAction must be taken immediately.
backtraces($message, $context)aModuleForce-log a message at INFO level together with a full stack trace/memory snapshot (iLogLevel::BACKTRACE), bypassing the verbosity mask entirely (any non-zero verbosity is enough to trigger it).
Configure($config)aModuleMerge $config into this module's configuration in the shared Configuration.
critical($message, $context)aModuleCritical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask.
debug($message, $context)aModuleDetailed debug information.
debugName()aModuleHuman-readable identifier used as the default {origin} in this instance's log messages.
emergency($message, $context)aModuleSystem is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask.
error($message, $context)aModuleRuntime errors that do not require immediate action but should typically be logged and monitored.
getVerbosity()aModule
info($message, $context)aModuleInteresting events. No-op if INFO is currently filtered out by the verbosity mask.
Instantiate($config)aModule(Re)create the shared instance immediately, configured with $config merged into the class's existing config.
IsShared()aModule
log($level, $message, $context)aModuleLogs with an arbitrary level.
notice($message, $context)aModuleNormal but significant events.
offsetExists($key)aModule\ArrayAccess::offsetExists -- tells whether $key is a declared property at all, regardless of whether it is currently readable/writable through array access.
offsetGet($key)aModule\ArrayAccess::offsetGet -- reads a property directly, unless it has a #[Serialize(serialize: 'methodName')] attribute, in which case that zero-argument method is called instead (e.g.
offsetSet($key, $value)aModule\ArrayAccess::offsetSet -- sets a property directly, unless it has a #[Serialize(unserialize: 'methodName')] attribute, in which case that method is called with $value instead (e.g.
offsetUnset($key)aModule\ArrayAccess::offsetUnset -- equivalent to $module[$key] = null.
serialize($path, $serializer)aModule\MMO\core\interfaces\iSerializable::serialize -- exports every property (via
setVerbosity($verb)aModuleSet the current verbosity mask, replacing whatever it was before.
Shared()aModuleGet the shared instance, creating (and configuring) it on first call.
testVerbosity($level)aModuleTest whether a given level (or set of levels) is currently enabled by this instance's verbosity mask.
traitUnshare($serialize)aModuleRemove the shared instance, so the next Shared() call creates a fresh one.
unserialize($data, $path, $instances)aModule\MMO\core\interfaces\iSerializable::unserialize -- merges $data onto DefaultConfig, runs it through the (possibly overridden) constructor, then applies each resulting value to its property (via
Unshare($serialize)aModuleLike tSingleton::Unshare, but also disconnects this module's instance from every event it was listening to (via Event::DisconnectListeners) before dropping it.
warning($message, $context)aModuleExceptional occurrences that are not errors.
__construct($config)aModuleprotected constructor, so it is not possible to do new Module(...) called by the serialization process just before being injected with data.