Skip to main content

Review events

Fired around the review subsystem. Reviews are first-class XF content with their own state machine, author replies, and notifier dispatch. The events let third parties hook every transition.

Events

EventSignatureWhen
mc_dm_review_pre_create(Review $review, Service\Review\Create $service)Before a brand-new review is saved. Pre-hook — throwing aborts.
mc_dm_review_post_create(Review $review, Service\Review\Create $service)After a brand-new review commits.
mc_dm_review_pre_save(Review $review, Service\Review\Edit $service)Before an edit commits.
mc_dm_review_post_save(Review $review, Service\Review\Edit $service)After an edit commits.
mc_dm_review_pre_delete(Review $review, string $mode, string $reason)Before a delete. $mode is 'soft' or 'hard'. $reason is empty for hard deletes.
mc_dm_review_post_delete(Review $review, string $mode)After delete commits.
mc_dm_review_state_change(Review $review, string $newState)After a state transition ('visible', 'deleted', 'moderated'). Fires from undelete and approve flows in addition to delete.
mc_dm_review_notifications_dispatched(Review $review, array $mentionedUsers)After the review notifier sends alerts/emails. $mentionedUsers is an array of User entities mentioned in the review body.
mc_dm_review_author_reply_added(Review $review)After a download author replies to a review.
mc_dm_review_author_reply_removed(Review $review)After an author reply is deleted.
mc_dm_review_author_reply_dispatched(Review $review)After the reply notifier sends the alert/email to the original reviewer.

Pre vs post

Pre-create / pre-save / pre-delete fire inside the service's transaction. Throwing aborts the operation. Post-* fire after commit.

State change vs delete

mc_dm_review_state_change is a superset of delete. Soft delete fires both pre_delete and state_change('deleted'). Undelete (restore) fires state_change('visible') only. If you only care about visibility transitions, subscribe to state_change. If you specifically need to react to deletion, use the delete events.

Example

public static function reviewPostCreate(
\MC\DownloadsManager\Entity\Review $review,
\MC\DownloadsManager\Service\Review\Create $service
)
{
// bump the author's review-count widget cache
}