X-Git-Url: https://git.agnieray.net/?a=blobdiff_plain;f=galette%2Flib%2FGalette%2FEntity%2FAdherent.php;h=e6d67b4d94282f039c845efa3ac25c9182bf9686;hb=b7b92f562e5817bd7fa164fdbbeadc44995cacfa;hp=9b844fc231ac148872596412f6bb271251f5e888;hpb=d92a9272f1e5f0dd21b32d625badc0869edacd9b;p=galette.git diff --git a/galette/lib/Galette/Entity/Adherent.php b/galette/lib/Galette/Entity/Adherent.php index 9b844fc23..e6d67b4d9 100644 --- a/galette/lib/Galette/Entity/Adherent.php +++ b/galette/lib/Galette/Entity/Adherent.php @@ -38,6 +38,7 @@ namespace Galette\Entity; use ArrayObject; use Galette\Events\GaletteEvent; +use Galette\Features\HasEvent; use Galette\Features\Socials; use Throwable; use Analog\Analog; @@ -126,6 +127,7 @@ class Adherent { use Dynamics; use Socials; + use HasEvent; public const TABLE = 'adherents'; public const PK = 'id_adh'; @@ -237,6 +239,12 @@ class Adherent } } + $this + ->withAddEvent() + ->withEditEvent() + ->withoutDeleteEvent() + ->activateEvents(); + if ($args == null || is_int($args)) { if (is_int($args) && $args > 0) { $this->load($args); @@ -1569,7 +1577,7 @@ class Adherent ); } - $event = 'member.add'; + $event = $this->getAddEventName(); } else { $hist->add(_T("Fail to add new member.")); throw new \Exception( @@ -1605,7 +1613,7 @@ class Adherent $this->sname ); } - $event = 'member.edit'; + $event = $this->getEditEventName(); } //dynamic fields @@ -1613,7 +1621,7 @@ class Adherent $this->storeSocials($this->id); //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 true; @@ -2267,4 +2275,14 @@ class Adherent $this->loadParent(); return $this; } + + /** + * Get prefix for events + * + * @return string + */ + protected function getEventsPrefix(): string + { + return 'member'; + } }