CoolCMS API

AdvertFollowerNotificationTrait

Notifies advert followers about a price change.

Price/price type/currency are dynamic parameters (parameterRels), so the snapshot from $meta (stored in beforeSave) is compared with the advert reloaded in afterSave.

Tags
requires

AdvertManager expects these members of the host class:

  • find(int $id, array $includes): ?Advert (GetTrait)
  • $advertFollowerManager->findAll(...) (AdvertFollowerManager)
  • $userManager->findAll(...) (System UserManager)
  • $emailManager->sendEmailToAll(...) (EmailManager)
  • getPresenterContext() (PresenterTrait)
  • $languageContext (LanguageTrait)

Table of Contents

Methods

extractPriceSnapshot()  : array<string, array<int, string|null>>
Snapshots the price-forming parameters (price / price type / currency).
notifyFollowersOnPriceChange()  : void
After an edit: when the price changed, sends `BZ_ADVERT_FOLLOWER` to all users who have an `AdvertFollower` on the advert.
sendFollowerEmails()  : void
Sends `BZ_ADVERT_FOLLOWER` to all followers in bulk with one `EmailManager::sendEmailToAll()` call (shared `$values`).
snapshotValues()  : array<int, string|null>
Returns the parameter values as a list of strings (`null` = empty value). Type `string` in `get()` returns strings or `null`; anything else counts as an empty value.

Methods

extractPriceSnapshot()

Snapshots the price-forming parameters (price / price type / currency).

private extractPriceSnapshot(Advert $advert) : array<string, array<int, string|null>>

Always returns arrays of values (alwaysReturnArray) so they can be compared with ===.

Parameters
$advert : Advert
Return values
array<string, array<int, string|null>>

notifyFollowersOnPriceChange()

After an edit: when the price changed, sends `BZ_ADVERT_FOLLOWER` to all users who have an `AdvertFollower` on the advert.

private notifyFollowersOnPriceChange(Advert $entity, array<string, mixed> $meta) : void
Parameters
$entity : Advert
$meta : array<string, mixed>

sendFollowerEmails()

Sends `BZ_ADVERT_FOLLOWER` to all followers in bulk with one `EmailManager::sendEmailToAll()` call (shared `$values`).

private sendFollowerEmails(Advert $advert, array<int, string> $emails) : void
Parameters
$advert : Advert
$emails : array<int, string>

snapshotValues()

Returns the parameter values as a list of strings (`null` = empty value). Type `string` in `get()` returns strings or `null`; anything else counts as an empty value.

private snapshotValues(Advert $advert, string $key) : array<int, string|null>
Parameters
$advert : Advert
$key : string
Return values
array<int, string|null>
On this page

Search results