X-Git-Url: https://git.agnieray.net/?a=blobdiff_plain;f=galette%2Flib%2FGalette%2FEntity%2FContribution.php;h=3457da44e01dc8437c3eeeb0d82943f3376dc18a;hb=b7b92f562e5817bd7fa164fdbbeadc44995cacfa;hp=f8cc8bd0db1e93ca8cf37ee7a0a2e1a896b65759;hpb=d92a9272f1e5f0dd21b32d625badc0869edacd9b;p=galette.git diff --git a/galette/lib/Galette/Entity/Contribution.php b/galette/lib/Galette/Entity/Contribution.php index f8cc8bd0d..3457da44e 100644 --- a/galette/lib/Galette/Entity/Contribution.php +++ b/galette/lib/Galette/Entity/Contribution.php @@ -40,6 +40,7 @@ namespace Galette\Entity; use ArrayObject; use DateTime; use Galette\Events\GaletteEvent; +use Galette\Features\HasEvent; use Throwable; use Analog\Analog; use Laminas\Db\Sql\Expression; @@ -85,6 +86,7 @@ use Galette\Features\Dynamics; class Contribution { use Dynamics; + use HasEvent; public const TABLE = 'cotisations'; public const PK = 'id_cotis'; @@ -135,6 +137,12 @@ class Contribution global $preferences; $this->_payment_type = (int)$preferences->pref_default_paymenttype; + $this + ->withAddEvent() + ->withEditEvent() + ->withoutDeleteEvent() + ->activateEvents(); + /* * Fields configuration. Each field is an array and must reflect: * array( @@ -683,7 +691,7 @@ class Contribution _T("Contribution added"), Adherent::getSName($this->zdb, $this->_member) ); - $event = 'contribution.add'; + $event = $this->getAddEventName(); } else { $hist->add(_T("Fail to add new contribution.")); throw new \Exception( @@ -705,7 +713,7 @@ class Contribution ); } - $event = 'contribution.edit'; + $event = $this->getEditEventName(); } //update deadline if ($this->isFee()) { @@ -719,7 +727,7 @@ class Contribution $this->_orig_amount = $this->_amount; //send event at the end of process, once all has been stored - if ($event !== null) { + if ($event !== null && $this->areEventsEnabled()) { $emitter->dispatch(new GaletteEvent($event, $this)); } @@ -1505,4 +1513,14 @@ class Contribution return false; } + + /** + * Get prefix for events + * + * @return string + */ + protected function getEventsPrefix(): string + { + return 'contribution'; + } }