Import chain

This page is the reference for every message in the import pipeline: what it imports, what it carries, and which child messages it dispatches. All messages live in HansPeterOrding\EspnApiSymfonyBundle\Message\EspnSync.

Anatomy of a message

Almost every message carries the same shape:

  • a reference — the ESPN $ref URL of the resource to import;

  • zero or more parent entity ids — the database ids of already-imported parents the new entity must be connected to;

  • an optional importEntities array — the import-control flags (Import control).

The parent ids matter: by the time a child message runs, its parent has already been persisted, so the child carries the parent’s database id (not its ESPN ref) to connect to it cheaply.

A handful of messages differ:

  • ImportEspnPositionsMessage carries no reference — it is a root trigger that lists all positions and dispatches one ImportEspnPositionMessage each.

  • ImportEspnTeamInjuriesMessage carries a teamId rather than a reference — it refreshes a team’s injuries.

Root triggers

These are the two entry points for a full import. Dispatch them yourself.

Season tree

Note

ImportEspnSeasonGroupMessage is recursive: a group dispatches messages for its child groups, walking the hierarchy until it reaches leaf groups. The parentGroupId carries the already-persisted parent so each group is linked to its parent.

Team tree

Message

Constructor

Dispatches

ImportEspnTeamMessage

(string $reference, int $seasonId, ?array $ie)

Venue, Franchise, Record, Athlete, Coach, TeamInjuries

ImportEspnVenueMessage

(string $reference, ?array $ie)

— (leaf)

ImportEspnFranchiseMessage

(string $reference, ?array $ie)

— (leaf)

ImportEspnRecordMessage

(string $reference, ?array $ie)

— (leaf)

ImportEspnCoachMessage

(string $reference, int $seasonId, ?array $ie)

— (leaf)

ImportEspnTeamInjuriesMessage

(int $teamId, ?array $ie)

Injury (after deleting the team’s current injuries)

Athlete tree

Message

Constructor

Dispatches

ImportEspnAthleteMessage

(string $reference, int $seasonId, ?array $ie)

Contract, Injury

ImportEspnContractMessage

(string $reference, int $athleteId, ?array $ie)

— (leaf)

ImportEspnInjuryMessage

(string $reference, ?array $ie)

— (leaf)

Note

An athlete’s notes are imported inline by the athlete importer (not as a separate message). The same is true for a team’s notes. Injuries are connected to all season instances of the athlete sharing the same espnId, because an injury is season-independent.

Event tree

Positions tree

Message

Constructor

Dispatches

ImportEspnPositionMessage

(string $reference, ?array $ie)

— (resolves its parent position inline)

Dispatching mid-chain

Because every message connects to its parents through ids it carries, you can enter the chain at any point — as long as the parents it references already exist in your database. This is the basis for targeted refreshes:

use HansPeterOrding\EspnApiSymfonyBundle\Message\EspnSync\ImportEspnTeamMessage;
use HansPeterOrding\EspnApiClient\ApiClient\EspnApiClientInterface;

// Re-import a single team (the season must already be imported)
$teamRef = EspnApiClientInterface::BASE_URI_SPORTS_CORE . 'seasons/2025/teams/12';

$bus->dispatch(new ImportEspnTeamMessage($teamRef, $seasonEntityId));

If a referenced parent is not present, the importer raises an unrecoverable error rather than guessing — see Error handling.