]>
git.agnieray.net Git - galette.git/blob - galette/lib/Galette/Features/HasEvent.php
8 * Copyright © 2024 The Galette Team
10 * This file is part of Galette (http://galette.tuxfamily.org).
12 * Galette is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * Galette is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
28 * @author Johan Cwiklinski <johan@x-tnd.be>
29 * @copyright 2024 The Galette Team
30 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
31 * @link https://galette.eu
34 namespace Galette\Features
;
42 * @author Johan Cwiklinski <johan@x-tnd.be>
43 * @copyright 2024 The Galette Team
44 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
45 * @link https://galette.eu
50 private bool $has_add_event = false;
51 private bool $has_edit_event = false;
52 private bool $has_delete_event = false;
53 protected bool $events_active = true;
56 * Get prefix for events
60 abstract protected function getEventsPrefix(): string;
67 public function activateEvents(): self
69 $this->events_active
= true;
78 public function disableEvents(): self
80 $this->events_active
= false;
89 public function areEventsEnabled(): bool
91 return $this->events_active
;
99 public function withAddEvent(): self
101 $this->has_add_event
= true;
110 public function withoutAddEvent(): self
112 $this->has_add_event
= false;
121 public function getAddEventName(): ?
string
123 if (!$this->hasAddEvent()) {
128 $this->getEventsPrefix()
137 public function hasAddEvent(): bool
139 return $this->areEventsEnabled() && $this->has_add_event
;
143 * Activate edit event
147 public function withEditEvent(): self
149 $this->has_edit_event
= true;
158 public function withoutEditEvent(): self
160 $this->has_edit_event
= false;
165 * Get edit event name
169 public function getEditEventName(): ?
string
171 if (!$this->hasEditEvent()) {
176 $this->getEventsPrefix()
185 public function hasEditEvent(): bool
187 return $this->areEventsEnabled() && $this->has_edit_event
;
195 public function withDeleteEvent(): self
197 $this->has_delete_event
= true;
202 * Disable delete event
206 public function withoutDeleteEvent(): self
208 $this->has_delete_event
= false;
213 * Get edit event name
217 public function getDeleteEventName(): ?
string
219 if (!$this->hasDeleteEvent()) {
224 $this->getEventsPrefix()
233 public function hasDeleteEvent(): bool
235 return $this->areEventsEnabled() && $this->has_delete_event
;