CoolCMS API

ProductImportEditTrait

Import `edit` action: job detail and the dry-run validation report.

  • summary numbers (created / updated / skipped / hard / soft),
  • paged preview of the line-based JSONL log with a level filter; the page comes from the Api bridge (ProductImportManager::getValidationReport()), which reads the file line by line, so even a huge log is never loaded whole,
  • download of the whole log (handleDownloadLog()),
  • job settings and "Validate again" (ProductImportSettingsFormTrait).

The report has two phases: validate (dry run) and execute (real run, a different log file). A job after a run (running/done/failed) shows execute by default; the template switches with reportPhase. The run buttons and status polling live in ProductImportRunTrait. A running job older than 30 minutes counts as stuck and offers "Mark as failed" (handleMarkFailed()); a failed job can be validated again (its settings stay editable) and run again.

Table of Contents

Constants

LOG_PAGE_SIZE  : int = 50
Log lines per report page.

Properties

$editedImport  : ProductImport|null
$validationReport  : array{summary: array, items: list, total: int, counts: array, page: int, perPage: int, hasLog: bool}|null
Data from the Api bridge travel through JSON, so their inside is `mixed` for the type system; the template and this trait therefore access it defensively (`?? 0`).

Methods

actionEdit()  : void
handleCancel()  : void
Cancels a job; the only state transition the UI exposes (`uploaded`/`validated`/`queued` to `cancelled`).
handleDelete()  : void
Handles the "Delete" button of the edit page. It lives outside the grid, so it has its own signal; the "not a running job" guard and file cleanup are done by {@see ApiProductImportManager} through Api hooks, same as the grid row action. The styled confirmation uses the global `data-grid-confirm` JS mechanism (works outside `.data-grid` too).
handleDownloadLog()  : void
Downloads the whole line-based log.
handleMarkFailed()  : void
Moves a stuck `running` job (crashed process or timeout) to `failed`; it can then be deleted or validated again.
handleRevalidate()  : void
Validates again without changing the settings; same path as after an upload.
renderEdit()  : void
canMarkProductImportFailed()  : bool
Tells whether "Mark as failed" is offered: only for a stuck run (`running` longer than {@see ApiProductImportManager::STALE_RUNNING_SECONDS}); a live run is never killed from the admin.
findProductImport()  : ProductImport|null
loadValidationReport()  : array{summary: array, items: list, total: int, counts: array, page: int, perPage: int, hasLog: bool}
resolveImportPrivatePath()  : string|null
resolveReportPhase()  : string
Resolves the report phase: `execute` after a real run, otherwise `validate`; an explicit parameter wins.

Constants

Properties

$validationReport

Data from the Api bridge travel through JSON, so their inside is `mixed` for the type system; the template and this trait therefore access it defensively (`?? 0`).

private array{summary: array, items: list, total: int, counts: array, page: int, perPage: int, hasLog: bool}|null $validationReport = null

Methods

actionEdit()

public actionEdit(int $id[, int $logPage = 1 ][, string|null $logLevel = null ][, string|null $reportPhase = null ]) : void
Parameters
$id : int
$logPage : int = 1
$logLevel : string|null = null
$reportPhase : string|null = null

handleCancel()

Cancels a job; the only state transition the UI exposes (`uploaded`/`validated`/`queued` to `cancelled`).

public handleCancel(int $id) : void
Parameters
$id : int
Attributes
#[Requires]
$methods: 'POST'

handleDelete()

Handles the "Delete" button of the edit page. It lives outside the grid, so it has its own signal; the "not a running job" guard and file cleanup are done by {@see ApiProductImportManager} through Api hooks, same as the grid row action. The styled confirmation uses the global `data-grid-confirm` JS mechanism (works outside `.data-grid` too).

public handleDelete(int $id) : void
Parameters
$id : int
Attributes
#[Requires]
$methods: 'POST'

handleDownloadLog()

Downloads the whole line-based log.

public handleDownloadLog(int $id[, string $phase = 'validate' ]) : void

IMPORTANT: the path is built from privateDir plus the logPath loaded from the job; only id comes from the request. Otherwise the signal would be a path traversal into the whole server.

Parameters
$id : int
$phase : string = 'validate'

handleMarkFailed()

Moves a stuck `running` job (crashed process or timeout) to `failed`; it can then be deleted or validated again.

public handleMarkFailed(int $id) : void
Parameters
$id : int
Attributes
#[Requires]
$methods: 'POST'

handleRevalidate()

Validates again without changing the settings; same path as after an upload.

public handleRevalidate(int $id) : void
Parameters
$id : int
Attributes
#[Requires]
$methods: 'POST'

renderEdit()

public renderEdit(int $id[, int $logPage = 1 ][, string|null $logLevel = null ][, string|null $reportPhase = null ]) : void
Parameters
$id : int
$logPage : int = 1
$logLevel : string|null = null
$reportPhase : string|null = null

canMarkProductImportFailed()

Tells whether "Mark as failed" is offered: only for a stuck run (`running` longer than {@see ApiProductImportManager::STALE_RUNNING_SECONDS}); a live run is never killed from the admin.

private canMarkProductImportFailed() : bool

The server-side guard is ProductImportManager::setState(); this is visibility only.

Return values
bool

loadValidationReport()

private loadValidationReport(int $id, int $logPage, string|null $logLevel[, string $phase = 'validate' ]) : array{summary: array, items: list, total: int, counts: array, page: int, perPage: int, hasLog: bool}
Parameters
$id : int
$logPage : int
$logLevel : string|null
$phase : string = 'validate'
Return values
array{summary: array, items: list, total: int, counts: array, page: int, perPage: int, hasLog: bool}

resolveImportPrivatePath()

private resolveImportPrivatePath(string $relative) : string|null
Parameters
$relative : string
Return values
string|null

resolveReportPhase()

Resolves the report phase: `execute` after a real run, otherwise `validate`; an explicit parameter wins.

private resolveReportPhase(string|null $requested) : string
Parameters
$requested : string|null
Return values
string
On this page

Search results