Feature: The profile update event carries the site and the origin 

Description 

\FGTCLB\AcademicPersons\Event\AfterProfileUpdateEvent carries two more values next to the profile:

  • getSite() returns the site the profile belongs to, when the dispatcher knows it, and null otherwise. A backend save passes the site of the profile's page and a frontend edit the site of its request; the commands pass none.
  • getOrigin() returns where the update came from, as a case of the new enum \FGTCLB\AcademicPersons\Event\ProfileUpdateOrigin : Creation and Synchronization for the frontend user commands, FrontendEditing for EXT:academic_persons_edit, Backend for a DataHandler save, Import for a DataHandler run marked as an import, and Unknown for a dispatcher that passes nothing.

Both are optional constructor arguments, so new AfterProfileUpdateEvent($profile) stays valid and yields no site and the origin Unknown. The case set of the enum is fixed; a listener may match over it exhaustively.

Import code that writes profiles through the DataHandler marks its run with the new enum \FGTCLB\AcademicPersons\DataHandling\ProfileWriteCorrelation , after start() , which replaces the correlation id:

$dataHandler->start($datamap, []);
$dataHandler->setCorrelationId(ProfileWriteCorrelation::Import->create());
$dataHandler->process_datamap();
Copied!

Its saves are then announced with the origin Import instead of Backend, see Important: Backend saves announce profile updates. ProfileWriteCorrelation::Internal marks a run that is never announced; a listener of the event that writes profiles through the DataHandler uses it for its own runs.

See AfterProfileUpdateEvent.

Impact 

Listeners can tell a backend save from an import and from a frontend edit, and defer or skip work for some of them. The translation synchronisation of EXT:academic_persons_edit takes the site from the event. Only for an event without one does it fall back to the site of the global request and then of the profile's page - except for a backend save or an import, which carry no site only when the profile's page belongs to none, and are then not synchronised.