Skip to main content

Version events

Fired around the publish or unpublish of an MC\DownloadsManager\Entity\DownloadVersion. These are independent of the parent download's download_state. A moderated download can have published versions, and a visible download can have unpublished drafts.

Events

EventSignatureWhen
mc_dm_version_pre_publish(DownloadVersion $version)Before is_published flips false to true.
mc_dm_version_post_publish(DownloadVersion $version)After publish commits.
mc_dm_version_unpublish(DownloadVersion $version)When is_published flips true to false.

Notes on the publish axis

  • is_published is independent of File.validation_status. A published version may carry files still being processed.
  • is_published = false routes the version through the approval queue. Only set false for genuinely-awaiting-mod cases. For author drafts, keep is_published = true and gate via the parent Download.download_state = 'draft'.

Typical use cases

  • Notify watchers on post_publish. See MC\DownloadsManager\Notifier\Version\NewVersion once notifications ship.
  • Build changelog entries on pre_publish. Read the previous version's metadata before the new one becomes the current version.
  • Trigger external CI on post_publish. Send a webhook to a build system or external sync target.

Example

public static function versionPostPublish(\MC\DownloadsManager\Entity\DownloadVersion $version)
{
$download = $version->Download;
\XF::app()->jobManager()->enqueue(
\YourAddon\Job\NotifyExternalSites::class,
['version_id' => $version->version_id]
);
}