use ArrayObject;
use DateTime;
use Galette\Events\GaletteEvent;
+use Galette\Features\HasEvent;
use Throwable;
use Analog\Analog;
use Laminas\Db\Sql\Expression;
class Contribution
{
use Dynamics;
+ use HasEvent;
public const TABLE = 'cotisations';
public const PK = 'id_cotis';
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(
_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(
);
}
- $event = 'contribution.edit';
+ $event = $this->getEditEventName();
}
//update deadline
if ($this->isFee()) {
$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));
}
return false;
}
+
+ /**
+ * Get prefix for events
+ *
+ * @return string
+ */
+ protected function getEventsPrefix(): string
+ {
+ return 'contribution';
+ }
}