MMOframework
Why AI Playground Libraries Documentation Search Agency
FR EN
Index

ImportJob

MMO\core\jobs · 1 symbol · generated 27 Oct 2026

class

ImportJob

ImportJob.php:36

An import as a long job (aJob): the importers of a configuration (Importer::FromMultipleConfigs), each reading its rows, one after the other, with each row's entities given to row before they are committed.

abstract class MMO\core\jobs\ImportJob extends MMO\core\jobs\aJob
Namespace
MMO\core\jobs
Extends
aJob
What [`ImportSocket`](https://mmoframework.fr/en/documentation/mmo.core/php/ImportSocket.md#importsocket) did over a websocket, followed instead like any job (`<mmo-job>`). A subclass gives the configuration ([`config`](https://mmoframework.fr/en/documentation/mmo.core/php/jobs/ImportJob.md#importjob-config)) and the rows of each importer ([`data`](https://mmoframework.fr/en/documentation/mmo.core/php/jobs/ImportJob.md#importjob-data)); [`row`](https://mmoframework.fr/en/documentation/mmo.core/php/jobs/ImportJob.md#importjob-row) checks or changes a row's entities, and [`ignore`](https://mmoframework.fr/en/documentation/mmo.core/php/jobs/ImportJob.md#importjob-ignore) drops one. It reports: - its progress, importer by importer (`{key}: row/rows`); - each row that failed (a log error), each entity left invalid (an html table at the end); - its result: by importer, by variable, how many were created, updated, ignored and invalid. Params (on top of the subclass's own): - `keys` (?array): only these importers, by key; - `dryRun` (bool): read and convert everything, commit nothing (relations to entities created by the same run are then not found).
class ProductsImportJob extends ImportJob { protected function config(array $params): string|array {return \MMO\filename('{root}/import/products.json');} protected function data(int|string $key, Importer $importer, array $params): ?iterable { return \MMO\core\files\csv(\MMO\filename("{root}/import/$key.csv")); } protected function row(int|string $index, array &$row, int|string $key, Importer $importer): void { if (empty($row['product']['sku'])) {$this->ignore($row, 'product');} } }

Index

counts
importer
key
config($params) abstract
count($row, $invalid)Count a row's entities by variable: created, updated, unchanged (ignored), invalid.
countReport()
data($key, $importer, $params) abstractThe rows an importer reads.
ignore($row, $name)Drop an entity of the row: it is not committed, and counted ignored.
importers($params)
invalidReport($invalid)
row($index, $row, $key, $importer)A row's entities, before they are committed: check them, change them, ignore some.
run($params)
Title() static
total($key, $rows, $params)How many rows an importer reads, for its progress.

Properties3

counts

protected array $counts = []
Type
array

importer

protected ?MMO\core\entities\Importer $importer = null
Type
null | Importer

key

protected string|int $key = ''
Type
string | int

Methods11

count($row, $invalid)

ImportJob.php:170

Count a row's entities by variable: created, updated, unchanged (ignored), invalid.

protected function count(array $row, array &$invalid): void
$rowarray
$invalidarraythe invalid ones, once each
returnsvoid

data($key, $importer, $params)

abstractImportJob.php:59

The rows an importer reads.

abstract protected function data(string|int $key, MMO\core\entities\Importer $importer, array $params): ?iterable
$keystring | intthe importer's key in the configuration
$importerImporter
$paramsarray
returnsnull | iterablenull to skip the importer

ignore($row, $name)

ImportJob.php:159

Drop an entity of the row: it is not committed, and counted ignored.

protected function ignore(array &$row, string $name): MMO\core\interfaces\iEntity|array|null
$rowarray
$namestringits variable
returnsiEntity | array | nullwhat was dropped

invalidReport($invalid)

ImportJob.php:203
protected function invalidReport(array $invalid): string
$invalidarray
returnsstringthe invalid entities and their errors, as an html table

row($index, $row, $key, $importer)

ImportJob.php:79

A row's entities, before they are committed: check them, change them, ignore some.

protected function row( string|int $index, array &$row, string|int $key, MMO\core\entities\Importer $importer ): void
$indexstring | intthe row's index in the importer's data
$rowarraythe entities of the row, by variable name
$keystring | intthe importer's key
$importerImporter
returnsvoid

Title()

staticImportJob.php:82
static function Title(): string
returnsstringwhat the import is: its importers run one after the other

total($key, $rows, $params)

ImportJob.php:68

How many rows an importer reads, for its progress.

protected function total(string|int $key, iterable $rows, array $params): ?int
$keystring | int
$rowsiterablewhat data returned
$paramsarray
returnsnull | intnull when unknown (a progress without a percentage)
Inherited members (56)
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
heartbeatIntervalaJob
idaJob
lastHeartbeataJob
lastProgressaJob
otherVerbosityaJob
progressaJob
progressIntervalaJob
progressSentaJob
stoppedaJob
storeaJob
verbosityaJob
MethodsDeclared byDescription
alert($message, $context)aJobAction must be taken immediately.
backtraces($message, $context)aJobForce-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).
critical($message, $context)aJobCritical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask.
debug($message, $context)aJobDetailed debug information.
debugName()aJob
emergency($message, $context)aJobSystem is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask.
emit($type, $data)aJobAdd an event of any type to the job's events (JobStore::emit).
error($message, $context)aJobRuntime errors that do not require immediate action but should typically be logged and monitored.
Exclusive()aJob
flushProgress($record)aJobSend the last progress if progress skipped it (what the job ends with).
getId()aJob
getStore()aJob
getVerbosity()aJob
heartbeat($changes, $force)aJobRefresh the record's heartbeat (with $changes), at most every $heartbeatInterval seconds.
html($html)aJobShow an html fragment as is (a report, a table): the people following the job see it in its log.
info($message, $context)aJobInteresting events. No-op if INFO is currently filtered out by the verbosity mask.
isStopped()aJob
log($level, $message, $context)aJobLogs with an arbitrary level.
notice($message, $context)aJobNormal but significant events.
progress($done, $total, $label)aJobSay how far the job is.
requestStop()aJobAsk the job to stop from inside its own process (what JobRunner does on SIGTERM).
setVerbosity($verb)aJobSet the current verbosity mask, replacing whatever it was before.
shouldStop()aJobWhether the job was asked to stop (JobStore::stop, or SIGTERM): call it in loops, and return when true.
testVerbosity($level)aJobTest whether a given level (or set of levels) is currently enabled by this instance's verbosity mask.
warning($message, $context)aJobExceptional occurrences that are not errors.
__construct($store, $id)aJob