WorkflowAdmin

Reference for the WorkflowAdmin module: an admin interface for human-processing workflows. Other modules register a workflow up front, supplying callbacks that produce the pending item ids, their count, their display names and the panel that processes one item; the admin section then lists every workflow, pages through its items, and drills into a single item for processing.

This page is a pure reference. For how the framework fits together, see the Guide.

Classes

WorkflowAdminConfig

Register the human-processing workflows a module needs, and read the registered set. Each workflow is keyed by module name and workflow name, and by a unique identifier. Registration is the cross-module configuration API for this module.

AddWorkflow

WorkflowAdminConfig::AddWorkflow(string $moduleName, string $workflowName, string $displayName, string $identifier, string $tableName, callable $entriesCallback, callable $countCallback, callable $sectionCallback, callable $displayNameCallback, string $listPagePath): void

Register a workflow for human processing. Throws when the identifier is already registered.

NameTypeDescription
$moduleNamestringModule name, used for error logging.
$workflowNamestringWorkflow name identifier.
$displayNamestringHuman-readable display name for the workflow.
$identifierstringUnique identifier; a UrlName starting with the module name and ending with Workflow.
$tableNamestringTable name for reference, displayed in the admin UI.
$entriesCallbackcallableReturns workflow item ids; receives a start and a limit, returns a list of ids.
$countCallbackcallableReturns the total count of workflow items.
$sectionCallbackcallableRenders the section for a workflow item; receives the row id.
$displayNameCallbackcallableReturns display names for ids; receives a list of ids, returns a map of id to display name.
$listPagePathstringAdmin path to the list page with filters applied.

Returns void

GetModuleNames

WorkflowAdminConfig::GetModuleNames(): array

The unique module names from the registered workflows, sorted alphabetically.

Returns array A list of module name strings.

GetWorkflow

WorkflowAdminConfig::GetWorkflow(string $moduleName, string $workflowName): ?WorkflowAdminConfigWorkflow

The registered workflow for a module name and workflow name, or null when none is registered.

NameTypeDescription
$moduleNamestringThe module the workflow belongs to.
$workflowNamestringThe workflow name.

Returns ?WorkflowAdminConfigWorkflow The workflow, or null.

GetWorkflowByIdentifier

WorkflowAdminConfig::GetWorkflowByIdentifier(string $identifier): ?WorkflowAdminConfigWorkflow

The registered workflow for a unique identifier, or null when none is registered.

NameTypeDescription
$identifierstringThe workflow identifier.

Returns ?WorkflowAdminConfigWorkflow The workflow, or null.

GetWorkflowNames

WorkflowAdminConfig::GetWorkflowNames(): array

The unique workflow names from the registered workflows, sorted.

Returns array A list of workflow name strings.

GetWorkflows

WorkflowAdminConfig::GetWorkflows(): array

Every registered workflow.

Returns array A list of WorkflowAdminConfigWorkflow.

GetWorkflowsByModule

WorkflowAdminConfig::GetWorkflowsByModule(): array

The registered workflows grouped by module name, sorted by module name.

Returns array A map of module name to a list of WorkflowAdminConfigWorkflow.

GetWorkflowsForModule

WorkflowAdminConfig::GetWorkflowsForModule(string $moduleName): array

The registered workflows for a single module.

NameTypeDescription
$moduleNamestringThe module to read workflows for.

Returns array A list of WorkflowAdminConfigWorkflow.

WorkflowAdminConfigWorkflow

A single registered workflow: its names and identifier, the reference table name, the four callbacks that drive it, and the list page path. Fields and constructor only.

Properties

PropertyTypeDescription
$workflow->moduleNamestringModule name, used for error logging (readonly).
$workflow->workflowNamestringWorkflow name identifier (readonly).
$workflow->displayNamestringHuman-readable display name (readonly).
$workflow->identifierstringUnique identifier (readonly).
$workflow->tableNamestringReference table name (readonly).
$workflow->entriesCallbackmixedCallback returning workflow item ids (readonly).
$workflow->countCallbackmixedCallback returning the total count of items (readonly).
$workflow->sectionCallbackmixedCallback rendering the section for an item (readonly).
$workflow->displayNameCallbackmixedCallback returning display names for ids (readonly).
$workflow->listPagePathstringAdmin path to the list page (readonly).

__construct

new WorkflowAdminConfigWorkflow(string $moduleName, string $workflowName, string $displayName, string $identifier, string $tableName, mixed $entriesCallback, mixed $countCallback, mixed $sectionCallback, mixed $displayNameCallback, string $listPagePath)

Create a registered workflow from its names, identifier, table name, callbacks and list page path.

NameTypeDescription
$moduleNamestringModule name, used for error logging.
$workflowNamestringWorkflow name identifier.
$displayNamestringHuman-readable display name.
$identifierstringUnique identifier.
$tableNamestringReference table name.
$entriesCallbackmixedCallback returning workflow item ids.
$countCallbackmixedCallback returning the total count of items.
$sectionCallbackmixedCallback rendering the section for an item.
$displayNameCallbackmixedCallback returning display names for ids.
$listPagePathstringAdmin path to the list page.

Returns WorkflowAdminConfigWorkflow

WorkflowAdminConfigWorkflowItem

A workflow item: its id paired with the database row it came from. Fields and constructor only.

Properties

PropertyTypeDescription
$item->idintThe workflow item id (readonly).
$item->rowobjectThe database row for the item (readonly).

__construct

new WorkflowAdminConfigWorkflowItem(int $id, object $row)

Create a workflow item from an id and its database row.

NameTypeDescription
$idintThe workflow item id.
$rowobjectThe database row for the item.

Returns WorkflowAdminConfigWorkflowItem

WorkflowAdminEntryData

A workflow entry: the id of a single pending workflow item, without the full row. Fields and constructor only.

Properties

PropertyTypeDescription
$entry->idintThe workflow item id (readonly).

__construct

new WorkflowAdminEntryData(int $id)

Create a workflow entry from an item id.

NameTypeDescription
$idintThe workflow item id.

Returns WorkflowAdminEntryData

WorkflowAdminDatabase

Read a workflow's size and its pending entries, by invoking the callbacks the workflow was registered with.

GetNextItemOptional

WorkflowAdminDatabase::GetNextItemOptional(WorkflowAdminConfigWorkflow $workflow): ?WorkflowAdminEntryData

The first pending entry of a workflow, or null when there are none.

NameTypeDescription
$workflowWorkflowAdminConfigWorkflowThe workflow to read from.

Returns ?WorkflowAdminEntryData The first entry, or null.

GetWorkflowEntries

WorkflowAdminDatabase::GetWorkflowEntries(WorkflowAdminConfigWorkflow $workflow, int $start = 0, int $limit = 10): array

A page of pending entries for a workflow, from an offset up to a limit.

NameTypeDescription
$workflowWorkflowAdminConfigWorkflowThe workflow to read from.
$startintThe offset to start from.
$limitintThe maximum number of entries to return, 1 to 1000.

Returns array A list of WorkflowAdminEntryData.

GetWorkflowSize

WorkflowAdminDatabase::GetWorkflowSize(WorkflowAdminConfigWorkflow $workflow): int

The current number of pending items in a workflow.

NameTypeDescription
$workflowWorkflowAdminConfigWorkflowThe workflow to measure.

Returns int The number of pending items.

WorkflowAdminUi

Registers the Workflow admin section, with its List and View sub-sections. Called by the module when it registers with the admin system.

Functions

Section

WorkflowAdminUi::Section(): void

Register the Workflow admin section, routing its List and View sub-sections.

Returns void

WorkflowAdminViewUi

The View section: lists every workflow identifier as navigation, then drills into a single workflow to page its items and view one at a time.

Section

WorkflowAdminViewUi::Section(): void

Render the View section: navigation over every registered workflow identifier, routing each into its own sub-section, and a redirect to the first.

Returns void

WorkflowSection

WorkflowAdminViewUi::WorkflowSection(WorkflowAdminConfigWorkflow $workflow, string $identifierUrlName): void

Render one workflow's section: a List tab paging its items, and a View tab drilling into a single item by id.

NameTypeDescription
$workflowWorkflowAdminConfigWorkflowThe workflow to render.
$identifierUrlNamestringThe workflow identifier lowercased, used in the path.

Returns void

WorkflowAdminPageUi

The pages of the admin section: the overview list of every workflow, a paged list of one workflow's items, and the view of a single item.

List

WorkflowAdminPageUi::List(): void

Render the overview: a table of every registered workflow with its module, identifier, display name, table, pending count and a view action.

Returns void

WorkflowItem

WorkflowAdminPageUi::WorkflowItem(WorkflowAdminConfigWorkflow $workflow, int $itemId, string $basePath): void

Render a single workflow item's page, calling the workflow's section callback to process it; shows an error when the item is no longer in the queue.

NameTypeDescription
$workflowWorkflowAdminConfigWorkflowThe workflow the item belongs to.
$itemIdintThe id of the item to view.
$basePathstringThe admin base path for the workflow.

Returns void

WorkflowItemList

WorkflowAdminPageUi::WorkflowItemList(WorkflowAdminConfigWorkflow $workflow, int $page = 1): void

Render a paged list of a workflow's pending items, with their ids, display names, a view action and the total pending count.

NameTypeDescription
$workflowWorkflowAdminConfigWorkflowThe workflow to list.
$pageintThe page number, starting at 1.

Returns void

WorkflowAdminPanelUi

Panels for the admin section: the overview panel, a per-workflow panel with its pending entries and details, and the panel that runs a workflow's processing callback for one item.

ListPanel

WorkflowAdminPanelUi::ListPanel(): void

Render a table of every registered workflow, with its module, identifier, display name, table, pending count and a view action.

Returns void

Panel

WorkflowAdminPanelUi::Panel(string $moduleName, string $workflowName): void

Render a panel for one workflow, found by module name and workflow name, showing up to ten pending entries and a view-all action; shows a not-found message when it is not registered.

NameTypeDescription
$moduleNamestringThe module the workflow belongs to.
$workflowNamestringThe workflow name.

Returns void

ProcessPanel

WorkflowAdminPanelUi::ProcessPanel(WorkflowAdminConfigWorkflow $workflow, int $rowId): void

Render the processing panel for one item by invoking the workflow's section callback, logging and showing an error status when the callback throws.

NameTypeDescription
$workflowWorkflowAdminConfigWorkflowThe workflow the item belongs to.
$rowIdintThe id of the item to process.

Returns void

Workflow

WorkflowAdminPanelUi::Workflow(WorkflowAdminConfigWorkflow $workflow): void

Render a panel for one workflow, showing up to ten pending entries, a view-all action and a collapsible details section.

NameTypeDescription
$workflowWorkflowAdminConfigWorkflowThe workflow to render.

Returns void