Skip to content

Reference

phil/migration

Announcing from a migration

TypeKindRole
AnnouncingMigrationabstract classA Doctrine AbstractMigration with note() and news()
AnnouncinginterfaceannounceWith(Announcements): what the factory calls
AnnouncestraitannounceWith(), note() and news(), for a base class of an application's own
Newsfinal readonly classA title, its lines and, maybe, a URL
AnnouncementsMissingLogicExceptionA migration announced without being given the announcements

note() takes one line per locale — ['fr' => '* Nouveau calendrier.', 'en' => '* A new calendar.'] — and news() one News per locale. A locale is a language, and maybe a region: fr or fr_CA. A note is a line of text; a piece of news has a title, and its URL is a URL or none. Anything else is an InvalidAnnouncement.

An application that has a base migration of its own uses the trait:

abstract class SiteMigration extends AbstractMigration implements Announcing
{
    use Announces;
}

What a run announces

TypeKindRole
Announcementsfinal classThe notes and news of a run, kept by the migration that left them
Releasefinal readonly classWhat the run announces, in the order the migrations ran; notesIn() and newsIn() by locale
AnnouncingMigrationFactorydecorates MigrationFactoryGives the announcements to every Announcing migration
AnnouncingMigratordecorates MigratorAnnounces the run once it is over

The migrator clears the announcements as a run starts, then, once it is over, keeps the notes and news of the migrations that ran to the end — neither skipped nor failed — in the order of the plan:

The runWhat is announced
ranevery migration that ran to the end
--dry-runnothing
failed, all or nothingnothing: everything was rolled back
failed, not all or nothingthe migrations that ran before the failure, which stay

Announcing comes after Doctrine committed, so a migration announced is a migration kept.

Channels

TypeKindRole
Channelfinal readonly classWhere and how a release is announced
ContentenumNotes or News
Announcerfinal readonly classAnnounces a release on every channel
PublisherinterfaceSends one message on a transport
ChatterPublisherfinal readonly classPublishes through the chatter of symfony/notifier
Channel argumentDefaultRole
transportThe chatter transport, as symfony/notifier names it
localeThe locale the announcement is read in; a note or a piece of news not written in it is left out
contentContent::NotesThe release notes, or the news
title''The title of the first message; none when empty
continued''The title of the messages that follow; none when empty
heading'{title}'The line of a piece of news that holds its title
link'{url}'The line that holds its URL; none when empty or when the news has no URL
maxLength2000The longest message, in characters: 2000 on Discord; 100 at least

A title takes half of a message at most. {counter} in title or continued becomes (2/3) when the release takes more than one message, and nothing when it takes one.

A channel that fails is logged as an error and left; the other channels are still told, and the migrations, which already ran, stay.

How messages are cut

The lines of a channel are put together, one per line, as long as the message, title and blank line included, fits maxLength; the next line starts the next message. A line too long alone is cut at its last space that fits, or in the middle of a word when none does. The room a title takes is counted with its counter, so a release of ten messages makes room for (10/10). Lengths are counted in characters, never in bytes.