@@ -23,252 +23,252 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class TaskSchedule |
| 25 | 25 | { |
| 26 | - private int $id; |
|
| 27 | - private bool $enabled; |
|
| 28 | - private string $task_id; |
|
| 29 | - private CarbonInterface $last_run; |
|
| 30 | - private bool $last_result; |
|
| 31 | - private int $frequency; |
|
| 32 | - private int $nb_occurrences; |
|
| 33 | - private bool $is_running; |
|
| 26 | + private int $id; |
|
| 27 | + private bool $enabled; |
|
| 28 | + private string $task_id; |
|
| 29 | + private CarbonInterface $last_run; |
|
| 30 | + private bool $last_result; |
|
| 31 | + private int $frequency; |
|
| 32 | + private int $nb_occurrences; |
|
| 33 | + private bool $is_running; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Constructor for TaskSchedule |
|
| 37 | - * |
|
| 38 | - * @param int $id Schedule ID |
|
| 39 | - * @param string $task_id Task ID |
|
| 40 | - * @param bool $enabled Is the schedule enabled |
|
| 41 | - * @param CarbonInterface $last_run Last successful run date/time |
|
| 42 | - * @param bool $last_result Result of the last run |
|
| 43 | - * @param int $frequency Schedule frequency in minutes |
|
| 44 | - * @param int $nb_occurrences Number of remaining occurrences to be run |
|
| 45 | - * @param bool $is_running Is the task currently running |
|
| 46 | - */ |
|
| 47 | - public function __construct( |
|
| 48 | - int $id, |
|
| 49 | - string $task_id, |
|
| 50 | - bool $enabled, |
|
| 51 | - CarbonInterface $last_run, |
|
| 52 | - bool $last_result, |
|
| 53 | - int $frequency, |
|
| 54 | - int $nb_occurrences, |
|
| 55 | - bool $is_running |
|
| 56 | - ) { |
|
| 57 | - $this->id = $id; |
|
| 58 | - $this->task_id = $task_id; |
|
| 59 | - $this->enabled = $enabled; |
|
| 60 | - $this->last_run = $last_run; |
|
| 61 | - $this->last_result = $last_result; |
|
| 62 | - $this->frequency = $frequency; |
|
| 63 | - $this->nb_occurrences = $nb_occurrences; |
|
| 64 | - $this->is_running = $is_running; |
|
| 65 | - } |
|
| 35 | + /** |
|
| 36 | + * Constructor for TaskSchedule |
|
| 37 | + * |
|
| 38 | + * @param int $id Schedule ID |
|
| 39 | + * @param string $task_id Task ID |
|
| 40 | + * @param bool $enabled Is the schedule enabled |
|
| 41 | + * @param CarbonInterface $last_run Last successful run date/time |
|
| 42 | + * @param bool $last_result Result of the last run |
|
| 43 | + * @param int $frequency Schedule frequency in minutes |
|
| 44 | + * @param int $nb_occurrences Number of remaining occurrences to be run |
|
| 45 | + * @param bool $is_running Is the task currently running |
|
| 46 | + */ |
|
| 47 | + public function __construct( |
|
| 48 | + int $id, |
|
| 49 | + string $task_id, |
|
| 50 | + bool $enabled, |
|
| 51 | + CarbonInterface $last_run, |
|
| 52 | + bool $last_result, |
|
| 53 | + int $frequency, |
|
| 54 | + int $nb_occurrences, |
|
| 55 | + bool $is_running |
|
| 56 | + ) { |
|
| 57 | + $this->id = $id; |
|
| 58 | + $this->task_id = $task_id; |
|
| 59 | + $this->enabled = $enabled; |
|
| 60 | + $this->last_run = $last_run; |
|
| 61 | + $this->last_result = $last_result; |
|
| 62 | + $this->frequency = $frequency; |
|
| 63 | + $this->nb_occurrences = $nb_occurrences; |
|
| 64 | + $this->is_running = $is_running; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Get the schedule ID. |
|
| 69 | - * |
|
| 70 | - * @return int |
|
| 71 | - */ |
|
| 72 | - public function id(): int |
|
| 73 | - { |
|
| 74 | - return $this->id; |
|
| 75 | - } |
|
| 67 | + /** |
|
| 68 | + * Get the schedule ID. |
|
| 69 | + * |
|
| 70 | + * @return int |
|
| 71 | + */ |
|
| 72 | + public function id(): int |
|
| 73 | + { |
|
| 74 | + return $this->id; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Get the task ID. |
|
| 79 | - * |
|
| 80 | - * @return string |
|
| 81 | - */ |
|
| 82 | - public function taskId(): string |
|
| 83 | - { |
|
| 84 | - return $this->task_id; |
|
| 85 | - } |
|
| 77 | + /** |
|
| 78 | + * Get the task ID. |
|
| 79 | + * |
|
| 80 | + * @return string |
|
| 81 | + */ |
|
| 82 | + public function taskId(): string |
|
| 83 | + { |
|
| 84 | + return $this->task_id; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * Returns whether the schedule is enabled |
|
| 89 | - * |
|
| 90 | - * @return bool |
|
| 91 | - */ |
|
| 92 | - public function isEnabled(): bool |
|
| 93 | - { |
|
| 94 | - return $this->enabled; |
|
| 95 | - } |
|
| 87 | + /** |
|
| 88 | + * Returns whether the schedule is enabled |
|
| 89 | + * |
|
| 90 | + * @return bool |
|
| 91 | + */ |
|
| 92 | + public function isEnabled(): bool |
|
| 93 | + { |
|
| 94 | + return $this->enabled; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Enable the schedule |
|
| 99 | - * |
|
| 100 | - * @return $this |
|
| 101 | - */ |
|
| 102 | - public function enable(): self |
|
| 103 | - { |
|
| 104 | - $this->enabled = true; |
|
| 105 | - return $this; |
|
| 106 | - } |
|
| 97 | + /** |
|
| 98 | + * Enable the schedule |
|
| 99 | + * |
|
| 100 | + * @return $this |
|
| 101 | + */ |
|
| 102 | + public function enable(): self |
|
| 103 | + { |
|
| 104 | + $this->enabled = true; |
|
| 105 | + return $this; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Disable the schedule |
|
| 110 | - * |
|
| 111 | - * @return $this |
|
| 112 | - */ |
|
| 113 | - public function disable(): self |
|
| 114 | - { |
|
| 115 | - $this->enabled = false; |
|
| 116 | - return $this; |
|
| 117 | - } |
|
| 108 | + /** |
|
| 109 | + * Disable the schedule |
|
| 110 | + * |
|
| 111 | + * @return $this |
|
| 112 | + */ |
|
| 113 | + public function disable(): self |
|
| 114 | + { |
|
| 115 | + $this->enabled = false; |
|
| 116 | + return $this; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Get the frequency of the schedule |
|
| 121 | - * |
|
| 122 | - * @return int |
|
| 123 | - */ |
|
| 124 | - public function frequency(): int |
|
| 125 | - { |
|
| 126 | - return $this->frequency; |
|
| 127 | - } |
|
| 119 | + /** |
|
| 120 | + * Get the frequency of the schedule |
|
| 121 | + * |
|
| 122 | + * @return int |
|
| 123 | + */ |
|
| 124 | + public function frequency(): int |
|
| 125 | + { |
|
| 126 | + return $this->frequency; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Set the frequency of the schedule |
|
| 131 | - * |
|
| 132 | - * @param int $frequency |
|
| 133 | - * @return $this |
|
| 134 | - */ |
|
| 135 | - public function setFrequency(int $frequency): self |
|
| 136 | - { |
|
| 137 | - $this->frequency = $frequency; |
|
| 138 | - return $this; |
|
| 139 | - } |
|
| 129 | + /** |
|
| 130 | + * Set the frequency of the schedule |
|
| 131 | + * |
|
| 132 | + * @param int $frequency |
|
| 133 | + * @return $this |
|
| 134 | + */ |
|
| 135 | + public function setFrequency(int $frequency): self |
|
| 136 | + { |
|
| 137 | + $this->frequency = $frequency; |
|
| 138 | + return $this; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Get the date/time of the last successful run. |
|
| 143 | - * |
|
| 144 | - * @return CarbonInterface |
|
| 145 | - */ |
|
| 146 | - public function lastRunTime(): CarbonInterface |
|
| 147 | - { |
|
| 148 | - return $this->last_run; |
|
| 149 | - } |
|
| 141 | + /** |
|
| 142 | + * Get the date/time of the last successful run. |
|
| 143 | + * |
|
| 144 | + * @return CarbonInterface |
|
| 145 | + */ |
|
| 146 | + public function lastRunTime(): CarbonInterface |
|
| 147 | + { |
|
| 148 | + return $this->last_run; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * Set the last successful run date/time |
|
| 153 | - * |
|
| 154 | - * @param CarbonInterface $last_run |
|
| 155 | - * @return $this |
|
| 156 | - */ |
|
| 157 | - public function setLastRunTime(CarbonInterface $last_run): self |
|
| 158 | - { |
|
| 159 | - $this->last_run = $last_run; |
|
| 160 | - return $this; |
|
| 161 | - } |
|
| 151 | + /** |
|
| 152 | + * Set the last successful run date/time |
|
| 153 | + * |
|
| 154 | + * @param CarbonInterface $last_run |
|
| 155 | + * @return $this |
|
| 156 | + */ |
|
| 157 | + public function setLastRunTime(CarbonInterface $last_run): self |
|
| 158 | + { |
|
| 159 | + $this->last_run = $last_run; |
|
| 160 | + return $this; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * Returns whether the last run was successful |
|
| 165 | - * |
|
| 166 | - * @return bool |
|
| 167 | - */ |
|
| 168 | - public function wasLastRunSuccess(): bool |
|
| 169 | - { |
|
| 170 | - return $this->last_result; |
|
| 171 | - } |
|
| 163 | + /** |
|
| 164 | + * Returns whether the last run was successful |
|
| 165 | + * |
|
| 166 | + * @return bool |
|
| 167 | + */ |
|
| 168 | + public function wasLastRunSuccess(): bool |
|
| 169 | + { |
|
| 170 | + return $this->last_result; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - /** |
|
| 174 | - * Set the last run result |
|
| 175 | - * |
|
| 176 | - * @param bool $last_result |
|
| 177 | - * @return $this |
|
| 178 | - */ |
|
| 179 | - public function setLastResult(bool $last_result): self |
|
| 180 | - { |
|
| 181 | - $this->last_result = $last_result; |
|
| 182 | - return $this; |
|
| 183 | - } |
|
| 173 | + /** |
|
| 174 | + * Set the last run result |
|
| 175 | + * |
|
| 176 | + * @param bool $last_result |
|
| 177 | + * @return $this |
|
| 178 | + */ |
|
| 179 | + public function setLastResult(bool $last_result): self |
|
| 180 | + { |
|
| 181 | + $this->last_result = $last_result; |
|
| 182 | + return $this; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Get the number of remaining of occurrences of task runs. |
|
| 187 | - * Returns 0 if the tasks must be run indefinitely. |
|
| 188 | - * |
|
| 189 | - * @return int |
|
| 190 | - */ |
|
| 191 | - public function remainingOccurrences(): int |
|
| 192 | - { |
|
| 193 | - return $this->nb_occurrences; |
|
| 194 | - } |
|
| 185 | + /** |
|
| 186 | + * Get the number of remaining of occurrences of task runs. |
|
| 187 | + * Returns 0 if the tasks must be run indefinitely. |
|
| 188 | + * |
|
| 189 | + * @return int |
|
| 190 | + */ |
|
| 191 | + public function remainingOccurrences(): int |
|
| 192 | + { |
|
| 193 | + return $this->nb_occurrences; |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - /** |
|
| 197 | - * Decrements the number of remaining occurrences by 1. |
|
| 198 | - * The task will be disabled when the number reaches 0. |
|
| 199 | - * |
|
| 200 | - * @return $this |
|
| 201 | - */ |
|
| 202 | - public function decrementRemainingOccurrences(): self |
|
| 203 | - { |
|
| 204 | - if ($this->nb_occurrences > 0) { |
|
| 205 | - $this->nb_occurrences--; |
|
| 206 | - if ($this->nb_occurrences === 0) { |
|
| 207 | - $this->disable(); |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - return $this; |
|
| 211 | - } |
|
| 196 | + /** |
|
| 197 | + * Decrements the number of remaining occurrences by 1. |
|
| 198 | + * The task will be disabled when the number reaches 0. |
|
| 199 | + * |
|
| 200 | + * @return $this |
|
| 201 | + */ |
|
| 202 | + public function decrementRemainingOccurrences(): self |
|
| 203 | + { |
|
| 204 | + if ($this->nb_occurrences > 0) { |
|
| 205 | + $this->nb_occurrences--; |
|
| 206 | + if ($this->nb_occurrences === 0) { |
|
| 207 | + $this->disable(); |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + return $this; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Set the number of remaining occurrences of task runs. |
|
| 215 | - * |
|
| 216 | - * @param int $nb_occurrences |
|
| 217 | - * @return $this |
|
| 218 | - */ |
|
| 219 | - public function setRemainingOccurrences(int $nb_occurrences): self |
|
| 220 | - { |
|
| 221 | - $this->nb_occurrences = $nb_occurrences; |
|
| 222 | - return $this; |
|
| 223 | - } |
|
| 213 | + /** |
|
| 214 | + * Set the number of remaining occurrences of task runs. |
|
| 215 | + * |
|
| 216 | + * @param int $nb_occurrences |
|
| 217 | + * @return $this |
|
| 218 | + */ |
|
| 219 | + public function setRemainingOccurrences(int $nb_occurrences): self |
|
| 220 | + { |
|
| 221 | + $this->nb_occurrences = $nb_occurrences; |
|
| 222 | + return $this; |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - /** |
|
| 226 | - * Returns whether the task is running |
|
| 227 | - * @return bool |
|
| 228 | - */ |
|
| 229 | - public function isRunning(): bool |
|
| 230 | - { |
|
| 231 | - return $this->is_running; |
|
| 232 | - } |
|
| 225 | + /** |
|
| 226 | + * Returns whether the task is running |
|
| 227 | + * @return bool |
|
| 228 | + */ |
|
| 229 | + public function isRunning(): bool |
|
| 230 | + { |
|
| 231 | + return $this->is_running; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - /** |
|
| 235 | - * Informs the schedule that the task is going to run |
|
| 236 | - * |
|
| 237 | - * @return $this |
|
| 238 | - */ |
|
| 239 | - public function startRunning(): self |
|
| 240 | - { |
|
| 241 | - $this->is_running = true; |
|
| 242 | - return $this; |
|
| 243 | - } |
|
| 234 | + /** |
|
| 235 | + * Informs the schedule that the task is going to run |
|
| 236 | + * |
|
| 237 | + * @return $this |
|
| 238 | + */ |
|
| 239 | + public function startRunning(): self |
|
| 240 | + { |
|
| 241 | + $this->is_running = true; |
|
| 242 | + return $this; |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - /** |
|
| 246 | - * Informs the schedule that the task has stopped running. |
|
| 247 | - * @return $this |
|
| 248 | - */ |
|
| 249 | - public function stopRunning(): self |
|
| 250 | - { |
|
| 251 | - $this->is_running = false; |
|
| 252 | - return $this; |
|
| 253 | - } |
|
| 245 | + /** |
|
| 246 | + * Informs the schedule that the task has stopped running. |
|
| 247 | + * @return $this |
|
| 248 | + */ |
|
| 249 | + public function stopRunning(): self |
|
| 250 | + { |
|
| 251 | + $this->is_running = false; |
|
| 252 | + return $this; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - /** |
|
| 256 | - * Returns the schedule details as an associate array |
|
| 257 | - * |
|
| 258 | - * @phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 259 | - * @return array{id: int, task_id: string, enabled: bool, last_run: CarbonInterface, last_result: bool, frequency: int, nb_occurrences: int, is_running: bool} |
|
| 260 | - */ |
|
| 261 | - public function toArray(): array |
|
| 262 | - { |
|
| 263 | - return [ |
|
| 264 | - 'id' => $this->id, |
|
| 265 | - 'task_id' => $this->task_id, |
|
| 266 | - 'enabled' => $this->enabled, |
|
| 267 | - 'last_run' => $this->last_run, |
|
| 268 | - 'last_result' => $this->last_result, |
|
| 269 | - 'frequency' => $this->frequency, |
|
| 270 | - 'nb_occurrences' => $this->nb_occurrences, |
|
| 271 | - 'is_running' => $this->is_running |
|
| 272 | - ]; |
|
| 273 | - } |
|
| 255 | + /** |
|
| 256 | + * Returns the schedule details as an associate array |
|
| 257 | + * |
|
| 258 | + * @phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 259 | + * @return array{id: int, task_id: string, enabled: bool, last_run: CarbonInterface, last_result: bool, frequency: int, nb_occurrences: int, is_running: bool} |
|
| 260 | + */ |
|
| 261 | + public function toArray(): array |
|
| 262 | + { |
|
| 263 | + return [ |
|
| 264 | + 'id' => $this->id, |
|
| 265 | + 'task_id' => $this->task_id, |
|
| 266 | + 'enabled' => $this->enabled, |
|
| 267 | + 'last_run' => $this->last_run, |
|
| 268 | + 'last_result' => $this->last_result, |
|
| 269 | + 'frequency' => $this->frequency, |
|
| 270 | + 'nb_occurrences' => $this->nb_occurrences, |
|
| 271 | + 'is_running' => $this->is_running |
|
| 272 | + ]; |
|
| 273 | + } |
|
| 274 | 274 | } |
@@ -28,39 +28,39 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class SosaComputeModal implements RequestHandlerInterface |
| 30 | 30 | { |
| 31 | - /** |
|
| 32 | - * @var SosaModule|null $module |
|
| 33 | - */ |
|
| 34 | - private $module; |
|
| 31 | + /** |
|
| 32 | + * @var SosaModule|null $module |
|
| 33 | + */ |
|
| 34 | + private $module; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Constructor for SosaComputeModal Request Handler |
|
| 38 | - * |
|
| 39 | - * @param ModuleService $module_service |
|
| 40 | - */ |
|
| 41 | - public function __construct(ModuleService $module_service) |
|
| 42 | - { |
|
| 43 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
| 44 | - } |
|
| 36 | + /** |
|
| 37 | + * Constructor for SosaComputeModal Request Handler |
|
| 38 | + * |
|
| 39 | + * @param ModuleService $module_service |
|
| 40 | + */ |
|
| 41 | + public function __construct(ModuleService $module_service) |
|
| 42 | + { |
|
| 43 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * {@inheritDoc} |
|
| 48 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 49 | - */ |
|
| 50 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 51 | - { |
|
| 52 | - if ($this->module === null) { |
|
| 53 | - return Registry::responseFactory()->response(view('modals/error', [ |
|
| 54 | - 'title' => I18N::translate('Error'), |
|
| 55 | - 'error' => I18N::translate('The attached module could not be found.') |
|
| 56 | - ])); |
|
| 57 | - } |
|
| 46 | + /** |
|
| 47 | + * {@inheritDoc} |
|
| 48 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 49 | + */ |
|
| 50 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 51 | + { |
|
| 52 | + if ($this->module === null) { |
|
| 53 | + return Registry::responseFactory()->response(view('modals/error', [ |
|
| 54 | + 'title' => I18N::translate('Error'), |
|
| 55 | + 'error' => I18N::translate('The attached module could not be found.') |
|
| 56 | + ])); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - $tree = Validator::attributes($request)->tree(); |
|
| 59 | + $tree = Validator::attributes($request)->tree(); |
|
| 60 | 60 | |
| 61 | - return Registry::responseFactory()->response(view($this->module->name() . '::modals/sosa-compute', [ |
|
| 62 | - 'tree' => $tree, |
|
| 63 | - 'xref' => Validator::attributes($request)->isXref()->string('xref', '') |
|
| 64 | - ])); |
|
| 65 | - } |
|
| 61 | + return Registry::responseFactory()->response(view($this->module->name() . '::modals/sosa-compute', [ |
|
| 62 | + 'tree' => $tree, |
|
| 63 | + 'xref' => Validator::attributes($request)->isXref()->string('xref', '') |
|
| 64 | + ])); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | |
| 59 | 59 | $tree = Validator::attributes($request)->tree(); |
| 60 | 60 | |
| 61 | - return Registry::responseFactory()->response(view($this->module->name() . '::modals/sosa-compute', [ |
|
| 61 | + return Registry::responseFactory()->response(view($this->module->name().'::modals/sosa-compute', [ |
|
| 62 | 62 | 'tree' => $tree, |
| 63 | 63 | 'xref' => Validator::attributes($request)->isXref()->string('xref', '') |
| 64 | 64 | ])); |
@@ -35,79 +35,79 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | class AncestorsListIndividual implements RequestHandlerInterface |
| 37 | 37 | { |
| 38 | - use ViewResponseTrait; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var SosaModule|null $module |
|
| 42 | - */ |
|
| 43 | - private $module; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @var SosaRecordsService $sosa_record_service |
|
| 47 | - */ |
|
| 48 | - private $sosa_record_service; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Constructor for AncestorsListIndividual Request Handler |
|
| 52 | - * |
|
| 53 | - * @param ModuleService $module_service |
|
| 54 | - * @param SosaRecordsService $sosa_record_service |
|
| 55 | - */ |
|
| 56 | - public function __construct( |
|
| 57 | - ModuleService $module_service, |
|
| 58 | - SosaRecordsService $sosa_record_service |
|
| 59 | - ) { |
|
| 60 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
| 61 | - $this->sosa_record_service = $sosa_record_service; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * {@inheritDoc} |
|
| 66 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 67 | - */ |
|
| 68 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 69 | - { |
|
| 70 | - $this->layout = 'layouts/ajax'; |
|
| 71 | - |
|
| 72 | - if ($this->module === null) { |
|
| 73 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - $tree = Validator::attributes($request)->tree(); |
|
| 77 | - $user = Auth::check() ? Validator::attributes($request)->user() : new DefaultUser(); |
|
| 78 | - $current_gen = Validator::attributes($request)->integer('gen', 0); |
|
| 79 | - |
|
| 80 | - if ($current_gen <= 0) { |
|
| 81 | - return Registry::responseFactory()->response( |
|
| 82 | - 'Invalid generation', |
|
| 83 | - StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY |
|
| 84 | - ); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $list_ancestors = $this->sosa_record_service->listAncestorsAtGeneration($tree, $user, $current_gen); |
|
| 88 | - $nb_ancestors_all = $list_ancestors->count(); |
|
| 89 | - |
|
| 90 | - /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */ |
|
| 91 | - $list_ancestors = $list_ancestors |
|
| 92 | - ->filter(function (stdClass $value) use ($tree): bool { |
|
| 93 | - $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
| 94 | - return $indi !== null && $indi->canShowName(); |
|
| 95 | - }) |
|
| 96 | - ->mapWithKeys(function (stdClass $value) use ($tree): array { |
|
| 97 | - $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
| 98 | - return [(int) $value->majs_sosa => $indi]; |
|
| 99 | - }); |
|
| 100 | - |
|
| 101 | - $nb_ancestors_shown = $list_ancestors->count(); |
|
| 102 | - |
|
| 103 | - return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [ |
|
| 104 | - 'module_name' => $this->module->name(), |
|
| 105 | - 'title' => I18N::translate('Sosa Ancestors'), |
|
| 106 | - 'tree' => $tree, |
|
| 107 | - 'list_ancestors' => $list_ancestors, |
|
| 108 | - 'nb_ancestors_all' => $nb_ancestors_all, |
|
| 109 | - 'nb_ancestors_theor' => pow(2, $current_gen - 1), |
|
| 110 | - 'nb_ancestors_shown' => $nb_ancestors_shown |
|
| 111 | - ]); |
|
| 112 | - } |
|
| 38 | + use ViewResponseTrait; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var SosaModule|null $module |
|
| 42 | + */ |
|
| 43 | + private $module; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @var SosaRecordsService $sosa_record_service |
|
| 47 | + */ |
|
| 48 | + private $sosa_record_service; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Constructor for AncestorsListIndividual Request Handler |
|
| 52 | + * |
|
| 53 | + * @param ModuleService $module_service |
|
| 54 | + * @param SosaRecordsService $sosa_record_service |
|
| 55 | + */ |
|
| 56 | + public function __construct( |
|
| 57 | + ModuleService $module_service, |
|
| 58 | + SosaRecordsService $sosa_record_service |
|
| 59 | + ) { |
|
| 60 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
| 61 | + $this->sosa_record_service = $sosa_record_service; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * {@inheritDoc} |
|
| 66 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 67 | + */ |
|
| 68 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 69 | + { |
|
| 70 | + $this->layout = 'layouts/ajax'; |
|
| 71 | + |
|
| 72 | + if ($this->module === null) { |
|
| 73 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + $tree = Validator::attributes($request)->tree(); |
|
| 77 | + $user = Auth::check() ? Validator::attributes($request)->user() : new DefaultUser(); |
|
| 78 | + $current_gen = Validator::attributes($request)->integer('gen', 0); |
|
| 79 | + |
|
| 80 | + if ($current_gen <= 0) { |
|
| 81 | + return Registry::responseFactory()->response( |
|
| 82 | + 'Invalid generation', |
|
| 83 | + StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY |
|
| 84 | + ); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $list_ancestors = $this->sosa_record_service->listAncestorsAtGeneration($tree, $user, $current_gen); |
|
| 88 | + $nb_ancestors_all = $list_ancestors->count(); |
|
| 89 | + |
|
| 90 | + /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */ |
|
| 91 | + $list_ancestors = $list_ancestors |
|
| 92 | + ->filter(function (stdClass $value) use ($tree): bool { |
|
| 93 | + $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
| 94 | + return $indi !== null && $indi->canShowName(); |
|
| 95 | + }) |
|
| 96 | + ->mapWithKeys(function (stdClass $value) use ($tree): array { |
|
| 97 | + $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
| 98 | + return [(int) $value->majs_sosa => $indi]; |
|
| 99 | + }); |
|
| 100 | + |
|
| 101 | + $nb_ancestors_shown = $list_ancestors->count(); |
|
| 102 | + |
|
| 103 | + return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [ |
|
| 104 | + 'module_name' => $this->module->name(), |
|
| 105 | + 'title' => I18N::translate('Sosa Ancestors'), |
|
| 106 | + 'tree' => $tree, |
|
| 107 | + 'list_ancestors' => $list_ancestors, |
|
| 108 | + 'nb_ancestors_all' => $nb_ancestors_all, |
|
| 109 | + 'nb_ancestors_theor' => pow(2, $current_gen - 1), |
|
| 110 | + 'nb_ancestors_shown' => $nb_ancestors_shown |
|
| 111 | + ]); |
|
| 112 | + } |
|
| 113 | 113 | } |
@@ -89,18 +89,18 @@ |
||
| 89 | 89 | |
| 90 | 90 | /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */ |
| 91 | 91 | $list_ancestors = $list_ancestors |
| 92 | - ->filter(function (stdClass $value) use ($tree): bool { |
|
| 92 | + ->filter(function(stdClass $value) use ($tree): bool { |
|
| 93 | 93 | $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
| 94 | 94 | return $indi !== null && $indi->canShowName(); |
| 95 | 95 | }) |
| 96 | - ->mapWithKeys(function (stdClass $value) use ($tree): array { |
|
| 96 | + ->mapWithKeys(function(stdClass $value) use ($tree): array { |
|
| 97 | 97 | $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
| 98 | - return [(int) $value->majs_sosa => $indi]; |
|
| 98 | + return [(int)$value->majs_sosa => $indi]; |
|
| 99 | 99 | }); |
| 100 | 100 | |
| 101 | 101 | $nb_ancestors_shown = $list_ancestors->count(); |
| 102 | 102 | |
| 103 | - return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [ |
|
| 103 | + return $this->viewResponse($this->module->name().'::list-ancestors-indi-tab', [ |
|
| 104 | 104 | 'module_name' => $this->module->name(), |
| 105 | 105 | 'title' => I18N::translate('Sosa Ancestors'), |
| 106 | 106 | 'tree' => $tree, |
@@ -35,78 +35,78 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | class AncestorsListFamily implements RequestHandlerInterface |
| 37 | 37 | { |
| 38 | - use ViewResponseTrait; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var SosaModule|null $module |
|
| 42 | - */ |
|
| 43 | - private $module; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @var SosaRecordsService $sosa_record_service |
|
| 47 | - */ |
|
| 48 | - private $sosa_record_service; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Constructor for AncestorsListFamily Request Handler |
|
| 52 | - * |
|
| 53 | - * @param ModuleService $module_service |
|
| 54 | - * @param SosaRecordsService $sosa_record_service |
|
| 55 | - */ |
|
| 56 | - public function __construct( |
|
| 57 | - ModuleService $module_service, |
|
| 58 | - SosaRecordsService $sosa_record_service |
|
| 59 | - ) { |
|
| 60 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
| 61 | - $this->sosa_record_service = $sosa_record_service; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * {@inheritDoc} |
|
| 66 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 67 | - */ |
|
| 68 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 69 | - { |
|
| 70 | - $this->layout = 'layouts/ajax'; |
|
| 71 | - |
|
| 72 | - if ($this->module === null) { |
|
| 73 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - $tree = Validator::attributes($request)->tree(); |
|
| 77 | - $user = Auth::check() ? Validator::attributes($request)->user() : new DefaultUser(); |
|
| 78 | - $current_gen = Validator::attributes($request)->integer('gen', 0); |
|
| 79 | - |
|
| 80 | - if ($current_gen <= 0) { |
|
| 81 | - return Registry::responseFactory()->response( |
|
| 82 | - 'Invalid generation', |
|
| 83 | - StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY |
|
| 84 | - ); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $list_families = $this->sosa_record_service->listAncestorFamiliesAtGeneration($tree, $user, $current_gen); |
|
| 88 | - $nb_families_all = $list_families->count(); |
|
| 89 | - |
|
| 90 | - /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Family> $list_families */ |
|
| 91 | - $list_families = $list_families |
|
| 92 | - ->filter(function (stdClass $value) use ($tree): bool { |
|
| 93 | - $fam = Registry::familyFactory()->make($value->f_id, $tree); |
|
| 94 | - return $fam !== null && $fam->canShow(); |
|
| 95 | - }) |
|
| 96 | - ->mapWithKeys(function (stdClass $value) use ($tree): array { |
|
| 97 | - $fam = Registry::familyFactory()->make($value->f_id, $tree); |
|
| 98 | - return [(int) $value->majs_sosa => $fam]; |
|
| 99 | - }); |
|
| 100 | - |
|
| 101 | - $nb_families_shown = $list_families->count(); |
|
| 102 | - |
|
| 103 | - return $this->viewResponse($this->module->name() . '::list-ancestors-fam-tab', [ |
|
| 104 | - 'module_name' => $this->module->name(), |
|
| 105 | - 'title' => I18N::translate('Sosa Ancestors'), |
|
| 106 | - 'tree' => $tree, |
|
| 107 | - 'list_families' => $list_families, |
|
| 108 | - 'nb_families_all' => $nb_families_all, |
|
| 109 | - 'nb_families_shown' => $nb_families_shown |
|
| 110 | - ]); |
|
| 111 | - } |
|
| 38 | + use ViewResponseTrait; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var SosaModule|null $module |
|
| 42 | + */ |
|
| 43 | + private $module; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @var SosaRecordsService $sosa_record_service |
|
| 47 | + */ |
|
| 48 | + private $sosa_record_service; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Constructor for AncestorsListFamily Request Handler |
|
| 52 | + * |
|
| 53 | + * @param ModuleService $module_service |
|
| 54 | + * @param SosaRecordsService $sosa_record_service |
|
| 55 | + */ |
|
| 56 | + public function __construct( |
|
| 57 | + ModuleService $module_service, |
|
| 58 | + SosaRecordsService $sosa_record_service |
|
| 59 | + ) { |
|
| 60 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
| 61 | + $this->sosa_record_service = $sosa_record_service; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * {@inheritDoc} |
|
| 66 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 67 | + */ |
|
| 68 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 69 | + { |
|
| 70 | + $this->layout = 'layouts/ajax'; |
|
| 71 | + |
|
| 72 | + if ($this->module === null) { |
|
| 73 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + $tree = Validator::attributes($request)->tree(); |
|
| 77 | + $user = Auth::check() ? Validator::attributes($request)->user() : new DefaultUser(); |
|
| 78 | + $current_gen = Validator::attributes($request)->integer('gen', 0); |
|
| 79 | + |
|
| 80 | + if ($current_gen <= 0) { |
|
| 81 | + return Registry::responseFactory()->response( |
|
| 82 | + 'Invalid generation', |
|
| 83 | + StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY |
|
| 84 | + ); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $list_families = $this->sosa_record_service->listAncestorFamiliesAtGeneration($tree, $user, $current_gen); |
|
| 88 | + $nb_families_all = $list_families->count(); |
|
| 89 | + |
|
| 90 | + /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Family> $list_families */ |
|
| 91 | + $list_families = $list_families |
|
| 92 | + ->filter(function (stdClass $value) use ($tree): bool { |
|
| 93 | + $fam = Registry::familyFactory()->make($value->f_id, $tree); |
|
| 94 | + return $fam !== null && $fam->canShow(); |
|
| 95 | + }) |
|
| 96 | + ->mapWithKeys(function (stdClass $value) use ($tree): array { |
|
| 97 | + $fam = Registry::familyFactory()->make($value->f_id, $tree); |
|
| 98 | + return [(int) $value->majs_sosa => $fam]; |
|
| 99 | + }); |
|
| 100 | + |
|
| 101 | + $nb_families_shown = $list_families->count(); |
|
| 102 | + |
|
| 103 | + return $this->viewResponse($this->module->name() . '::list-ancestors-fam-tab', [ |
|
| 104 | + 'module_name' => $this->module->name(), |
|
| 105 | + 'title' => I18N::translate('Sosa Ancestors'), |
|
| 106 | + 'tree' => $tree, |
|
| 107 | + 'list_families' => $list_families, |
|
| 108 | + 'nb_families_all' => $nb_families_all, |
|
| 109 | + 'nb_families_shown' => $nb_families_shown |
|
| 110 | + ]); |
|
| 111 | + } |
|
| 112 | 112 | } |
@@ -89,18 +89,18 @@ |
||
| 89 | 89 | |
| 90 | 90 | /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Family> $list_families */ |
| 91 | 91 | $list_families = $list_families |
| 92 | - ->filter(function (stdClass $value) use ($tree): bool { |
|
| 92 | + ->filter(function(stdClass $value) use ($tree): bool { |
|
| 93 | 93 | $fam = Registry::familyFactory()->make($value->f_id, $tree); |
| 94 | 94 | return $fam !== null && $fam->canShow(); |
| 95 | 95 | }) |
| 96 | - ->mapWithKeys(function (stdClass $value) use ($tree): array { |
|
| 96 | + ->mapWithKeys(function(stdClass $value) use ($tree): array { |
|
| 97 | 97 | $fam = Registry::familyFactory()->make($value->f_id, $tree); |
| 98 | - return [(int) $value->majs_sosa => $fam]; |
|
| 98 | + return [(int)$value->majs_sosa => $fam]; |
|
| 99 | 99 | }); |
| 100 | 100 | |
| 101 | 101 | $nb_families_shown = $list_families->count(); |
| 102 | 102 | |
| 103 | - return $this->viewResponse($this->module->name() . '::list-ancestors-fam-tab', [ |
|
| 103 | + return $this->viewResponse($this->module->name().'::list-ancestors-fam-tab', [ |
|
| 104 | 104 | 'module_name' => $this->module->name(), |
| 105 | 105 | 'title' => I18N::translate('Sosa Ancestors'), |
| 106 | 106 | 'tree' => $tree, |
@@ -32,101 +32,101 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class SosaByGenerationGeoAnalysis implements GeoAnalysisInterface |
| 34 | 34 | { |
| 35 | - private SosaRecordsService $records_service; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Constructor for SosaByGenerationGeoAnalysis |
|
| 39 | - * |
|
| 40 | - * @param SosaRecordsService $records_service |
|
| 41 | - */ |
|
| 42 | - public function __construct(SosaRecordsService $records_service) |
|
| 43 | - { |
|
| 44 | - $this->records_service = $records_service; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * {@inheritDoc} |
|
| 49 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::title() |
|
| 50 | - */ |
|
| 51 | - public function title(): string |
|
| 52 | - { |
|
| 53 | - return I18N::translate('Sosa ancestors places by generation'); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * {@inheritDoc} |
|
| 58 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::itemsDescription() |
|
| 59 | - */ |
|
| 60 | - public function itemsDescription(): callable |
|
| 61 | - { |
|
| 62 | - return fn(int $count): string => I18N::plural('ancestor', 'ancestors', $count); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * {@inheritDoc} |
|
| 67 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::results() |
|
| 68 | - */ |
|
| 69 | - public function results(Tree $tree, int $depth): GeoAnalysisResults |
|
| 70 | - { |
|
| 71 | - $results = new GeoAnalysisResults(); |
|
| 72 | - |
|
| 73 | - $unique_ancestors = $this->records_service |
|
| 74 | - ->listAncestors($tree, Auth::check() ? Auth::user() : new DefaultUser()) |
|
| 75 | - ->uniqueStrict(fn(stdClass $item): string => $item->majs_i_id); |
|
| 76 | - |
|
| 77 | - foreach ($unique_ancestors as $item) { |
|
| 78 | - $ancestor = Registry::individualFactory()->make($item->majs_i_id, $tree); |
|
| 79 | - if ($ancestor === null || !$ancestor->canShow()) { |
|
| 80 | - continue; |
|
| 81 | - } |
|
| 82 | - $generation = $this->records_service->generation((int) $item->majs_sosa); |
|
| 83 | - $significantplace = new GeoAnalysisPlace($tree, null, $depth); |
|
| 84 | - foreach ($this->significantPlaces($ancestor) as $place) { |
|
| 85 | - $significantplace = new GeoAnalysisPlace($tree, $place, $depth, true); |
|
| 86 | - if ($significantplace->isKnown()) { |
|
| 87 | - break; |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - $results->addPlace($significantplace); |
|
| 91 | - $results->addPlaceInCategory( |
|
| 92 | - I18N::translate('Generation %s', I18N::number($generation)), |
|
| 93 | - $generation, |
|
| 94 | - $significantplace |
|
| 95 | - ); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - return $results; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Returns significant places in order of priority for an individual |
|
| 103 | - * |
|
| 104 | - * @param Individual $individual |
|
| 105 | - * @return Generator<\Fisharebest\Webtrees\Place> |
|
| 106 | - */ |
|
| 107 | - protected function significantPlaces(Individual $individual): Generator |
|
| 108 | - { |
|
| 109 | - yield $individual->getBirthPlace(); |
|
| 110 | - |
|
| 111 | - /** @var \Fisharebest\Webtrees\Fact $fact */ |
|
| 112 | - foreach ($individual->facts(['RESI']) as $fact) { |
|
| 113 | - yield $fact->place(); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - yield $individual->getDeathPlace(); |
|
| 117 | - |
|
| 118 | - /** @var \Fisharebest\Webtrees\Family $family */ |
|
| 119 | - foreach ($individual->childFamilies() as $family) { |
|
| 120 | - foreach ($family->facts(['RESI']) as $fact) { |
|
| 121 | - yield $fact->place(); |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** @var \Fisharebest\Webtrees\Family $family */ |
|
| 126 | - foreach ($individual->spouseFamilies() as $family) { |
|
| 127 | - foreach ($family->facts(['RESI']) as $fact) { |
|
| 128 | - yield $fact->place(); |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - } |
|
| 35 | + private SosaRecordsService $records_service; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Constructor for SosaByGenerationGeoAnalysis |
|
| 39 | + * |
|
| 40 | + * @param SosaRecordsService $records_service |
|
| 41 | + */ |
|
| 42 | + public function __construct(SosaRecordsService $records_service) |
|
| 43 | + { |
|
| 44 | + $this->records_service = $records_service; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * {@inheritDoc} |
|
| 49 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::title() |
|
| 50 | + */ |
|
| 51 | + public function title(): string |
|
| 52 | + { |
|
| 53 | + return I18N::translate('Sosa ancestors places by generation'); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * {@inheritDoc} |
|
| 58 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::itemsDescription() |
|
| 59 | + */ |
|
| 60 | + public function itemsDescription(): callable |
|
| 61 | + { |
|
| 62 | + return fn(int $count): string => I18N::plural('ancestor', 'ancestors', $count); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * {@inheritDoc} |
|
| 67 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::results() |
|
| 68 | + */ |
|
| 69 | + public function results(Tree $tree, int $depth): GeoAnalysisResults |
|
| 70 | + { |
|
| 71 | + $results = new GeoAnalysisResults(); |
|
| 72 | + |
|
| 73 | + $unique_ancestors = $this->records_service |
|
| 74 | + ->listAncestors($tree, Auth::check() ? Auth::user() : new DefaultUser()) |
|
| 75 | + ->uniqueStrict(fn(stdClass $item): string => $item->majs_i_id); |
|
| 76 | + |
|
| 77 | + foreach ($unique_ancestors as $item) { |
|
| 78 | + $ancestor = Registry::individualFactory()->make($item->majs_i_id, $tree); |
|
| 79 | + if ($ancestor === null || !$ancestor->canShow()) { |
|
| 80 | + continue; |
|
| 81 | + } |
|
| 82 | + $generation = $this->records_service->generation((int) $item->majs_sosa); |
|
| 83 | + $significantplace = new GeoAnalysisPlace($tree, null, $depth); |
|
| 84 | + foreach ($this->significantPlaces($ancestor) as $place) { |
|
| 85 | + $significantplace = new GeoAnalysisPlace($tree, $place, $depth, true); |
|
| 86 | + if ($significantplace->isKnown()) { |
|
| 87 | + break; |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + $results->addPlace($significantplace); |
|
| 91 | + $results->addPlaceInCategory( |
|
| 92 | + I18N::translate('Generation %s', I18N::number($generation)), |
|
| 93 | + $generation, |
|
| 94 | + $significantplace |
|
| 95 | + ); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + return $results; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Returns significant places in order of priority for an individual |
|
| 103 | + * |
|
| 104 | + * @param Individual $individual |
|
| 105 | + * @return Generator<\Fisharebest\Webtrees\Place> |
|
| 106 | + */ |
|
| 107 | + protected function significantPlaces(Individual $individual): Generator |
|
| 108 | + { |
|
| 109 | + yield $individual->getBirthPlace(); |
|
| 110 | + |
|
| 111 | + /** @var \Fisharebest\Webtrees\Fact $fact */ |
|
| 112 | + foreach ($individual->facts(['RESI']) as $fact) { |
|
| 113 | + yield $fact->place(); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + yield $individual->getDeathPlace(); |
|
| 117 | + |
|
| 118 | + /** @var \Fisharebest\Webtrees\Family $family */ |
|
| 119 | + foreach ($individual->childFamilies() as $family) { |
|
| 120 | + foreach ($family->facts(['RESI']) as $fact) { |
|
| 121 | + yield $fact->place(); |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** @var \Fisharebest\Webtrees\Family $family */ |
|
| 126 | + foreach ($individual->spouseFamilies() as $family) { |
|
| 127 | + foreach ($family->facts(['RESI']) as $fact) { |
|
| 128 | + yield $fact->place(); |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | 132 | } |
@@ -72,14 +72,14 @@ |
||
| 72 | 72 | |
| 73 | 73 | $unique_ancestors = $this->records_service |
| 74 | 74 | ->listAncestors($tree, Auth::check() ? Auth::user() : new DefaultUser()) |
| 75 | - ->uniqueStrict(fn(stdClass $item): string => $item->majs_i_id); |
|
| 75 | + ->uniqueStrict(fn(stdClass $item) : string => $item->majs_i_id); |
|
| 76 | 76 | |
| 77 | 77 | foreach ($unique_ancestors as $item) { |
| 78 | 78 | $ancestor = Registry::individualFactory()->make($item->majs_i_id, $tree); |
| 79 | 79 | if ($ancestor === null || !$ancestor->canShow()) { |
| 80 | 80 | continue; |
| 81 | 81 | } |
| 82 | - $generation = $this->records_service->generation((int) $item->majs_sosa); |
|
| 82 | + $generation = $this->records_service->generation((int)$item->majs_sosa); |
|
| 83 | 83 | $significantplace = new GeoAnalysisPlace($tree, null, $depth); |
| 84 | 84 | foreach ($this->significantPlaces($ancestor) as $place) { |
| 85 | 85 | $significantplace = new GeoAnalysisPlace($tree, $place, $depth, true); |
@@ -27,52 +27,52 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class SosaIconHook implements RecordNameTextExtenderInterface |
| 29 | 29 | { |
| 30 | - private ModuleInterface $module; |
|
| 31 | - private SosaRecordsService $sosa_records_service; |
|
| 30 | + private ModuleInterface $module; |
|
| 31 | + private SosaRecordsService $sosa_records_service; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Constructor for SosaIconHook |
|
| 35 | - * |
|
| 36 | - * @param ModuleInterface $module |
|
| 37 | - * @param SosaRecordsService $sosa_records_service |
|
| 38 | - */ |
|
| 39 | - public function __construct(ModuleInterface $module, SosaRecordsService $sosa_records_service) |
|
| 40 | - { |
|
| 41 | - $this->module = $module; |
|
| 42 | - $this->sosa_records_service = $sosa_records_service; |
|
| 43 | - } |
|
| 33 | + /** |
|
| 34 | + * Constructor for SosaIconHook |
|
| 35 | + * |
|
| 36 | + * @param ModuleInterface $module |
|
| 37 | + * @param SosaRecordsService $sosa_records_service |
|
| 38 | + */ |
|
| 39 | + public function __construct(ModuleInterface $module, SosaRecordsService $sosa_records_service) |
|
| 40 | + { |
|
| 41 | + $this->module = $module; |
|
| 42 | + $this->sosa_records_service = $sosa_records_service; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * {@inheritDoc} |
|
| 47 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
|
| 48 | - */ |
|
| 49 | - public function module(): ModuleInterface |
|
| 50 | - { |
|
| 51 | - return $this->module; |
|
| 52 | - } |
|
| 45 | + /** |
|
| 46 | + * {@inheritDoc} |
|
| 47 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
|
| 48 | + */ |
|
| 49 | + public function module(): ModuleInterface |
|
| 50 | + { |
|
| 51 | + return $this->module; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * {@inheritDoc} |
|
| 56 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend() |
|
| 57 | - */ |
|
| 58 | - public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
| 59 | - { |
|
| 60 | - return ''; |
|
| 61 | - } |
|
| 54 | + /** |
|
| 55 | + * {@inheritDoc} |
|
| 56 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend() |
|
| 57 | + */ |
|
| 58 | + public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
| 59 | + { |
|
| 60 | + return ''; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * {@inheritDoc} |
|
| 65 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend() |
|
| 66 | - */ |
|
| 67 | - public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
| 68 | - { |
|
| 69 | - $current_user = Auth::check() ? Auth::user() : new DefaultUser(); |
|
| 70 | - if ( |
|
| 71 | - $record instanceof Individual && |
|
| 72 | - $this->sosa_records_service->isSosa($record->tree(), $current_user, $record) |
|
| 73 | - ) { |
|
| 74 | - return view($this->module->name() . '::icons/sosa', [ 'size_style' => $size ]); |
|
| 75 | - } |
|
| 76 | - return ''; |
|
| 77 | - } |
|
| 63 | + /** |
|
| 64 | + * {@inheritDoc} |
|
| 65 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend() |
|
| 66 | + */ |
|
| 67 | + public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
| 68 | + { |
|
| 69 | + $current_user = Auth::check() ? Auth::user() : new DefaultUser(); |
|
| 70 | + if ( |
|
| 71 | + $record instanceof Individual && |
|
| 72 | + $this->sosa_records_service->isSosa($record->tree(), $current_user, $record) |
|
| 73 | + ) { |
|
| 74 | + return view($this->module->name() . '::icons/sosa', [ 'size_style' => $size ]); |
|
| 75 | + } |
|
| 76 | + return ''; |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | $record instanceof Individual && |
| 72 | 72 | $this->sosa_records_service->isSosa($record->tree(), $current_user, $record) |
| 73 | 73 | ) { |
| 74 | - return view($this->module->name() . '::icons/sosa', [ 'size_style' => $size ]); |
|
| 74 | + return view($this->module->name().'::icons/sosa', ['size_style' => $size]); |
|
| 75 | 75 | } |
| 76 | 76 | return ''; |
| 77 | 77 | } |
@@ -41,165 +41,165 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | class HealthCheckEmailTask implements TaskInterface, ConfigurableTaskInterface |
| 43 | 43 | { |
| 44 | - /** |
|
| 45 | - * Name of the Tree preference to check if the task is enabled for that tree |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 48 | - public const TREE_PREFERENCE_NAME = 'MAJ_AT_HEALTHCHECK_ENABLED'; |
|
| 49 | - |
|
| 50 | - private ?AdminTasksModule $module; |
|
| 51 | - private HealthCheckService $healthcheck_service; |
|
| 52 | - private EmailService $email_service; |
|
| 53 | - private UserService $user_service; |
|
| 54 | - private TreeService $tree_service; |
|
| 55 | - private UpgradeService $upgrade_service; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Constructor for HealthCheckTask |
|
| 59 | - * |
|
| 60 | - * @param ModuleService $module_service |
|
| 61 | - * @param HealthCheckService $healthcheck_service |
|
| 62 | - * @param EmailService $email_service |
|
| 63 | - * @param UserService $user_service |
|
| 64 | - * @param TreeService $tree_service |
|
| 65 | - * @param UpgradeService $upgrade_service |
|
| 66 | - */ |
|
| 67 | - public function __construct( |
|
| 68 | - ModuleService $module_service, |
|
| 69 | - HealthCheckService $healthcheck_service, |
|
| 70 | - EmailService $email_service, |
|
| 71 | - UserService $user_service, |
|
| 72 | - TreeService $tree_service, |
|
| 73 | - UpgradeService $upgrade_service |
|
| 74 | - ) { |
|
| 75 | - $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
| 76 | - $this->healthcheck_service = $healthcheck_service; |
|
| 77 | - $this->email_service = $email_service; |
|
| 78 | - $this->user_service = $user_service; |
|
| 79 | - $this->tree_service = $tree_service; |
|
| 80 | - $this->upgrade_service = $upgrade_service; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * {@inheritDoc} |
|
| 86 | - * @see \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface::name() |
|
| 87 | - */ |
|
| 88 | - public function name(): string |
|
| 89 | - { |
|
| 90 | - return I18N::translate('Healthcheck Email'); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * {@inheritDoc} |
|
| 95 | - * @see \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface::defaultFrequency() |
|
| 96 | - */ |
|
| 97 | - public function defaultFrequency(): int |
|
| 98 | - { |
|
| 99 | - return 10080; // = 1 week = 7 * 24 * 60 min |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * {@inheritDoc} |
|
| 104 | - * @see \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface::run() |
|
| 105 | - */ |
|
| 106 | - public function run(TaskSchedule $task_schedule): bool |
|
| 107 | - { |
|
| 108 | - if ($this->module === null) { |
|
| 109 | - return false; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $res = true; |
|
| 113 | - |
|
| 114 | - // Compute the number of days to compute |
|
| 115 | - $interval_lastrun = $task_schedule->lastRunTime()->diffAsCarbonInterval(CarbonImmutable::now()); |
|
| 116 | - $interval_frequency = CarbonInterval::minutes($task_schedule->frequency()); |
|
| 117 | - $interval = $interval_lastrun->greaterThan($interval_frequency) ? $interval_lastrun : $interval_frequency; |
|
| 118 | - $nb_days = (int) $interval->ceilDay()->totalDays; |
|
| 119 | - |
|
| 120 | - $view_params_site = [ |
|
| 121 | - 'nb_days' => $nb_days, |
|
| 122 | - 'upgrade_available' => $this->upgrade_service->isUpgradeAvailable(), |
|
| 123 | - 'latest_version' => $this->upgrade_service->latestVersion(), |
|
| 124 | - 'download_url' => $this->upgrade_service->downloadUrl(), |
|
| 125 | - 'all_users' => $this->user_service->all(), |
|
| 126 | - 'unapproved' => $this->user_service->unapproved(), |
|
| 127 | - 'unverified' => $this->user_service->unverified(), |
|
| 128 | - ]; |
|
| 129 | - |
|
| 130 | - foreach ($this->tree_service->all() as $tree) { |
|
| 131 | - /** @var Tree $tree */ |
|
| 132 | - |
|
| 133 | - if ($tree->getPreference(self::TREE_PREFERENCE_NAME) !== '1') { |
|
| 134 | - continue; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - $webmaster = $this->user_service->find((int) $tree->getPreference('WEBMASTER_USER_ID')); |
|
| 138 | - if ($webmaster === null) { |
|
| 139 | - continue; |
|
| 140 | - } |
|
| 141 | - I18N::init($webmaster->getPreference('language')); |
|
| 142 | - |
|
| 143 | - $error_logs = $this->healthcheck_service->errorLogs($tree, $nb_days); |
|
| 144 | - $nb_errors = $error_logs->sum('nblogs'); |
|
| 145 | - |
|
| 146 | - $view_params = $view_params_site + [ |
|
| 147 | - 'tree' => $tree, |
|
| 148 | - 'total_by_type' => $this->healthcheck_service->countByRecordType($tree), |
|
| 149 | - 'change_by_type' => $this->healthcheck_service->changesByRecordType($tree, $nb_days), |
|
| 150 | - 'error_logs' => $error_logs, |
|
| 151 | - 'nb_errors' => $nb_errors |
|
| 152 | - ]; |
|
| 153 | - |
|
| 154 | - $res = $res && $this->email_service->send( |
|
| 155 | - new TreeUser($tree), |
|
| 156 | - $webmaster, |
|
| 157 | - new NoReplyUser(), |
|
| 158 | - I18N::translate('Health Check Report') . ' - ' . I18N::translate('Tree %s', $tree->name()), |
|
| 159 | - view($this->module->name() . '::tasks/healthcheck/email-healthcheck-text', $view_params), |
|
| 160 | - view($this->module->name() . '::tasks/healthcheck/email-healthcheck-html', $view_params) |
|
| 161 | - ); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - return $res; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * {@inheritDoc} |
|
| 169 | - * @see \MyArtJaub\Webtrees\Contracts\Tasks\ConfigurableTaskInterface::configView() |
|
| 170 | - */ |
|
| 171 | - public function configView(ServerRequestInterface $request): string |
|
| 172 | - { |
|
| 173 | - return $this->module === null ? '' : view($this->module->name() . '::tasks/healthcheck/config', [ |
|
| 174 | - 'all_trees' => $this->tree_service->all() |
|
| 175 | - ]); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * {@inheritDoc} |
|
| 180 | - * @see \MyArtJaub\Webtrees\Contracts\Tasks\ConfigurableTaskInterface::updateConfig() |
|
| 181 | - */ |
|
| 182 | - public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool |
|
| 183 | - { |
|
| 184 | - try { |
|
| 185 | - $validator = Validator::parsedBody($request); |
|
| 186 | - |
|
| 187 | - foreach ($this->tree_service->all() as $tree) { |
|
| 188 | - if (Auth::isManager($tree)) { |
|
| 189 | - $tree_enabled = $validator->boolean('HEALTHCHECK_ENABLED_' . $tree->id(), false); |
|
| 190 | - $tree->setPreference(self::TREE_PREFERENCE_NAME, $tree_enabled ? '1' : '0'); |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - return true; |
|
| 194 | - } catch (Throwable $ex) { |
|
| 195 | - Log::addErrorLog( |
|
| 196 | - sprintf( |
|
| 197 | - 'Error while updating the Task schedule "%s". Exception: %s', |
|
| 198 | - $task_schedule->id(), |
|
| 199 | - $ex->getMessage() |
|
| 200 | - ) |
|
| 201 | - ); |
|
| 202 | - } |
|
| 203 | - return false; |
|
| 204 | - } |
|
| 44 | + /** |
|
| 45 | + * Name of the Tree preference to check if the task is enabled for that tree |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | + public const TREE_PREFERENCE_NAME = 'MAJ_AT_HEALTHCHECK_ENABLED'; |
|
| 49 | + |
|
| 50 | + private ?AdminTasksModule $module; |
|
| 51 | + private HealthCheckService $healthcheck_service; |
|
| 52 | + private EmailService $email_service; |
|
| 53 | + private UserService $user_service; |
|
| 54 | + private TreeService $tree_service; |
|
| 55 | + private UpgradeService $upgrade_service; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Constructor for HealthCheckTask |
|
| 59 | + * |
|
| 60 | + * @param ModuleService $module_service |
|
| 61 | + * @param HealthCheckService $healthcheck_service |
|
| 62 | + * @param EmailService $email_service |
|
| 63 | + * @param UserService $user_service |
|
| 64 | + * @param TreeService $tree_service |
|
| 65 | + * @param UpgradeService $upgrade_service |
|
| 66 | + */ |
|
| 67 | + public function __construct( |
|
| 68 | + ModuleService $module_service, |
|
| 69 | + HealthCheckService $healthcheck_service, |
|
| 70 | + EmailService $email_service, |
|
| 71 | + UserService $user_service, |
|
| 72 | + TreeService $tree_service, |
|
| 73 | + UpgradeService $upgrade_service |
|
| 74 | + ) { |
|
| 75 | + $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
| 76 | + $this->healthcheck_service = $healthcheck_service; |
|
| 77 | + $this->email_service = $email_service; |
|
| 78 | + $this->user_service = $user_service; |
|
| 79 | + $this->tree_service = $tree_service; |
|
| 80 | + $this->upgrade_service = $upgrade_service; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * {@inheritDoc} |
|
| 86 | + * @see \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface::name() |
|
| 87 | + */ |
|
| 88 | + public function name(): string |
|
| 89 | + { |
|
| 90 | + return I18N::translate('Healthcheck Email'); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * {@inheritDoc} |
|
| 95 | + * @see \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface::defaultFrequency() |
|
| 96 | + */ |
|
| 97 | + public function defaultFrequency(): int |
|
| 98 | + { |
|
| 99 | + return 10080; // = 1 week = 7 * 24 * 60 min |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * {@inheritDoc} |
|
| 104 | + * @see \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface::run() |
|
| 105 | + */ |
|
| 106 | + public function run(TaskSchedule $task_schedule): bool |
|
| 107 | + { |
|
| 108 | + if ($this->module === null) { |
|
| 109 | + return false; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $res = true; |
|
| 113 | + |
|
| 114 | + // Compute the number of days to compute |
|
| 115 | + $interval_lastrun = $task_schedule->lastRunTime()->diffAsCarbonInterval(CarbonImmutable::now()); |
|
| 116 | + $interval_frequency = CarbonInterval::minutes($task_schedule->frequency()); |
|
| 117 | + $interval = $interval_lastrun->greaterThan($interval_frequency) ? $interval_lastrun : $interval_frequency; |
|
| 118 | + $nb_days = (int) $interval->ceilDay()->totalDays; |
|
| 119 | + |
|
| 120 | + $view_params_site = [ |
|
| 121 | + 'nb_days' => $nb_days, |
|
| 122 | + 'upgrade_available' => $this->upgrade_service->isUpgradeAvailable(), |
|
| 123 | + 'latest_version' => $this->upgrade_service->latestVersion(), |
|
| 124 | + 'download_url' => $this->upgrade_service->downloadUrl(), |
|
| 125 | + 'all_users' => $this->user_service->all(), |
|
| 126 | + 'unapproved' => $this->user_service->unapproved(), |
|
| 127 | + 'unverified' => $this->user_service->unverified(), |
|
| 128 | + ]; |
|
| 129 | + |
|
| 130 | + foreach ($this->tree_service->all() as $tree) { |
|
| 131 | + /** @var Tree $tree */ |
|
| 132 | + |
|
| 133 | + if ($tree->getPreference(self::TREE_PREFERENCE_NAME) !== '1') { |
|
| 134 | + continue; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + $webmaster = $this->user_service->find((int) $tree->getPreference('WEBMASTER_USER_ID')); |
|
| 138 | + if ($webmaster === null) { |
|
| 139 | + continue; |
|
| 140 | + } |
|
| 141 | + I18N::init($webmaster->getPreference('language')); |
|
| 142 | + |
|
| 143 | + $error_logs = $this->healthcheck_service->errorLogs($tree, $nb_days); |
|
| 144 | + $nb_errors = $error_logs->sum('nblogs'); |
|
| 145 | + |
|
| 146 | + $view_params = $view_params_site + [ |
|
| 147 | + 'tree' => $tree, |
|
| 148 | + 'total_by_type' => $this->healthcheck_service->countByRecordType($tree), |
|
| 149 | + 'change_by_type' => $this->healthcheck_service->changesByRecordType($tree, $nb_days), |
|
| 150 | + 'error_logs' => $error_logs, |
|
| 151 | + 'nb_errors' => $nb_errors |
|
| 152 | + ]; |
|
| 153 | + |
|
| 154 | + $res = $res && $this->email_service->send( |
|
| 155 | + new TreeUser($tree), |
|
| 156 | + $webmaster, |
|
| 157 | + new NoReplyUser(), |
|
| 158 | + I18N::translate('Health Check Report') . ' - ' . I18N::translate('Tree %s', $tree->name()), |
|
| 159 | + view($this->module->name() . '::tasks/healthcheck/email-healthcheck-text', $view_params), |
|
| 160 | + view($this->module->name() . '::tasks/healthcheck/email-healthcheck-html', $view_params) |
|
| 161 | + ); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + return $res; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * {@inheritDoc} |
|
| 169 | + * @see \MyArtJaub\Webtrees\Contracts\Tasks\ConfigurableTaskInterface::configView() |
|
| 170 | + */ |
|
| 171 | + public function configView(ServerRequestInterface $request): string |
|
| 172 | + { |
|
| 173 | + return $this->module === null ? '' : view($this->module->name() . '::tasks/healthcheck/config', [ |
|
| 174 | + 'all_trees' => $this->tree_service->all() |
|
| 175 | + ]); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * {@inheritDoc} |
|
| 180 | + * @see \MyArtJaub\Webtrees\Contracts\Tasks\ConfigurableTaskInterface::updateConfig() |
|
| 181 | + */ |
|
| 182 | + public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool |
|
| 183 | + { |
|
| 184 | + try { |
|
| 185 | + $validator = Validator::parsedBody($request); |
|
| 186 | + |
|
| 187 | + foreach ($this->tree_service->all() as $tree) { |
|
| 188 | + if (Auth::isManager($tree)) { |
|
| 189 | + $tree_enabled = $validator->boolean('HEALTHCHECK_ENABLED_' . $tree->id(), false); |
|
| 190 | + $tree->setPreference(self::TREE_PREFERENCE_NAME, $tree_enabled ? '1' : '0'); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + return true; |
|
| 194 | + } catch (Throwable $ex) { |
|
| 195 | + Log::addErrorLog( |
|
| 196 | + sprintf( |
|
| 197 | + 'Error while updating the Task schedule "%s". Exception: %s', |
|
| 198 | + $task_schedule->id(), |
|
| 199 | + $ex->getMessage() |
|
| 200 | + ) |
|
| 201 | + ); |
|
| 202 | + } |
|
| 203 | + return false; |
|
| 204 | + } |
|
| 205 | 205 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $interval_lastrun = $task_schedule->lastRunTime()->diffAsCarbonInterval(CarbonImmutable::now()); |
| 116 | 116 | $interval_frequency = CarbonInterval::minutes($task_schedule->frequency()); |
| 117 | 117 | $interval = $interval_lastrun->greaterThan($interval_frequency) ? $interval_lastrun : $interval_frequency; |
| 118 | - $nb_days = (int) $interval->ceilDay()->totalDays; |
|
| 118 | + $nb_days = (int)$interval->ceilDay()->totalDays; |
|
| 119 | 119 | |
| 120 | 120 | $view_params_site = [ |
| 121 | 121 | 'nb_days' => $nb_days, |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | continue; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $webmaster = $this->user_service->find((int) $tree->getPreference('WEBMASTER_USER_ID')); |
|
| 137 | + $webmaster = $this->user_service->find((int)$tree->getPreference('WEBMASTER_USER_ID')); |
|
| 138 | 138 | if ($webmaster === null) { |
| 139 | 139 | continue; |
| 140 | 140 | } |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | new TreeUser($tree), |
| 156 | 156 | $webmaster, |
| 157 | 157 | new NoReplyUser(), |
| 158 | - I18N::translate('Health Check Report') . ' - ' . I18N::translate('Tree %s', $tree->name()), |
|
| 159 | - view($this->module->name() . '::tasks/healthcheck/email-healthcheck-text', $view_params), |
|
| 160 | - view($this->module->name() . '::tasks/healthcheck/email-healthcheck-html', $view_params) |
|
| 158 | + I18N::translate('Health Check Report').' - '.I18N::translate('Tree %s', $tree->name()), |
|
| 159 | + view($this->module->name().'::tasks/healthcheck/email-healthcheck-text', $view_params), |
|
| 160 | + view($this->module->name().'::tasks/healthcheck/email-healthcheck-html', $view_params) |
|
| 161 | 161 | ); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function configView(ServerRequestInterface $request): string |
| 172 | 172 | { |
| 173 | - return $this->module === null ? '' : view($this->module->name() . '::tasks/healthcheck/config', [ |
|
| 173 | + return $this->module === null ? '' : view($this->module->name().'::tasks/healthcheck/config', [ |
|
| 174 | 174 | 'all_trees' => $this->tree_service->all() |
| 175 | 175 | ]); |
| 176 | 176 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | foreach ($this->tree_service->all() as $tree) { |
| 188 | 188 | if (Auth::isManager($tree)) { |
| 189 | - $tree_enabled = $validator->boolean('HEALTHCHECK_ENABLED_' . $tree->id(), false); |
|
| 189 | + $tree_enabled = $validator->boolean('HEALTHCHECK_ENABLED_'.$tree->id(), false); |
|
| 190 | 190 | $tree->setPreference(self::TREE_PREFERENCE_NAME, $tree_enabled ? '1' : '0'); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -32,92 +32,92 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class TasksList implements RequestHandlerInterface |
| 34 | 34 | { |
| 35 | - private ?AdminTasksModule $module; |
|
| 36 | - private TaskScheduleService $taskschedules_service; |
|
| 35 | + private ?AdminTasksModule $module; |
|
| 36 | + private TaskScheduleService $taskschedules_service; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Constructor for TasksList Request Handler |
|
| 40 | - * |
|
| 41 | - * @param ModuleService $module_service |
|
| 42 | - * @param TaskScheduleService $taskschedules_service |
|
| 43 | - */ |
|
| 44 | - public function __construct( |
|
| 45 | - ModuleService $module_service, |
|
| 46 | - TaskScheduleService $taskschedules_service |
|
| 47 | - ) { |
|
| 48 | - $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
| 49 | - $this->taskschedules_service = $taskschedules_service; |
|
| 50 | - } |
|
| 38 | + /** |
|
| 39 | + * Constructor for TasksList Request Handler |
|
| 40 | + * |
|
| 41 | + * @param ModuleService $module_service |
|
| 42 | + * @param TaskScheduleService $taskschedules_service |
|
| 43 | + */ |
|
| 44 | + public function __construct( |
|
| 45 | + ModuleService $module_service, |
|
| 46 | + TaskScheduleService $taskschedules_service |
|
| 47 | + ) { |
|
| 48 | + $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
| 49 | + $this->taskschedules_service = $taskschedules_service; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * {@inheritDoc} |
|
| 54 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 55 | - */ |
|
| 56 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 57 | - { |
|
| 58 | - if ($this->module === null) { |
|
| 59 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 60 | - } |
|
| 52 | + /** |
|
| 53 | + * {@inheritDoc} |
|
| 54 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 55 | + */ |
|
| 56 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 57 | + { |
|
| 58 | + if ($this->module === null) { |
|
| 59 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - $module = $this->module; |
|
| 63 | - $module_name = $this->module->name(); |
|
| 64 | - return Registry::responseFactory()->response(['data' => $this->taskschedules_service->all(true, true) |
|
| 65 | - ->map(function (TaskSchedule $schedule) use ($module, $module_name): array { |
|
| 66 | - $task = $this->taskschedules_service->findTask($schedule->taskId()); |
|
| 67 | - $task_name = $task !== null ? $task->name() : I18N::translate('Task not found'); |
|
| 68 | - $last_run_timestamp = Registry::timestampFactory()->make($schedule->lastRunTime()->getTimestamp()); |
|
| 62 | + $module = $this->module; |
|
| 63 | + $module_name = $this->module->name(); |
|
| 64 | + return Registry::responseFactory()->response(['data' => $this->taskschedules_service->all(true, true) |
|
| 65 | + ->map(function (TaskSchedule $schedule) use ($module, $module_name): array { |
|
| 66 | + $task = $this->taskschedules_service->findTask($schedule->taskId()); |
|
| 67 | + $task_name = $task !== null ? $task->name() : I18N::translate('Task not found'); |
|
| 68 | + $last_run_timestamp = Registry::timestampFactory()->make($schedule->lastRunTime()->getTimestamp()); |
|
| 69 | 69 | |
| 70 | - return [ |
|
| 71 | - 'edit' => view($module_name . '::admin/tasks-table-options', [ |
|
| 72 | - 'task_sched_id' => $schedule->id(), |
|
| 73 | - 'task_sched_enabled' => $schedule->isEnabled(), |
|
| 74 | - 'task_edit_route' => route(TaskEditPage::class, ['task' => $schedule->id()]), |
|
| 75 | - 'task_status_route' => route(TaskStatusAction::class, [ |
|
| 76 | - 'task' => $schedule->id(), |
|
| 77 | - 'enable' => $schedule->isEnabled() ? 0 : 1 |
|
| 78 | - ]) |
|
| 79 | - ]), |
|
| 80 | - 'status' => [ |
|
| 81 | - 'display' => view($module_name . '::components/yes-no-icons', [ |
|
| 82 | - 'yes' => $schedule->isEnabled() |
|
| 83 | - ]), |
|
| 84 | - 'raw' => $schedule->isEnabled() ? 1 : 0 |
|
| 85 | - ], |
|
| 86 | - 'task_name' => [ |
|
| 87 | - 'display' => '<bdi>' . e($task_name) . '</bdi>', |
|
| 88 | - 'raw' => $task_name |
|
| 89 | - ], |
|
| 90 | - 'last_run' => [ |
|
| 91 | - 'display' => $last_run_timestamp->timestamp() === 0 ? |
|
| 92 | - view('components/datetime', ['timestamp' => $last_run_timestamp]) : |
|
| 93 | - view('components/datetime-diff', ['timestamp' => $last_run_timestamp]), |
|
| 94 | - 'raw' => $schedule->lastRunTime()->getTimestamp() |
|
| 95 | - ], |
|
| 96 | - 'last_result' => [ |
|
| 97 | - 'display' => view($module_name . '::components/yes-no-icons', [ |
|
| 98 | - 'yes' => $schedule->wasLastRunSuccess() |
|
| 99 | - ]), |
|
| 100 | - 'raw' => $schedule->wasLastRunSuccess() ? 1 : 0 |
|
| 101 | - ], |
|
| 102 | - 'frequency' => |
|
| 103 | - '<bdi>' . e(CarbonInterval::minutes($schedule->frequency())->cascade()->forHumans()) . '</bdi>', |
|
| 104 | - 'nb_occurrences' => $schedule->remainingOccurrences() > 0 ? |
|
| 105 | - I18N::number($schedule->remainingOccurrences()) : |
|
| 106 | - I18N::translate('Unlimited'), |
|
| 107 | - 'running' => view($module_name . '::components/yes-no-icons', [ |
|
| 108 | - 'yes' => $schedule->isRunning(), |
|
| 109 | - 'text_yes' => I18N::translate('Running'), |
|
| 110 | - 'text_no' => I18N::translate('Not running') |
|
| 111 | - ]), |
|
| 112 | - 'run' => view($module_name . '::admin/tasks-table-run', [ |
|
| 113 | - 'task_sched_id' => $schedule->id(), |
|
| 114 | - 'run_route' => route(TaskTrigger::class, [ |
|
| 115 | - 'task' => $schedule->taskId(), |
|
| 116 | - 'force' => $module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN') |
|
| 117 | - ]) |
|
| 118 | - ]) |
|
| 119 | - ]; |
|
| 120 | - }) |
|
| 121 | - ]); |
|
| 122 | - } |
|
| 70 | + return [ |
|
| 71 | + 'edit' => view($module_name . '::admin/tasks-table-options', [ |
|
| 72 | + 'task_sched_id' => $schedule->id(), |
|
| 73 | + 'task_sched_enabled' => $schedule->isEnabled(), |
|
| 74 | + 'task_edit_route' => route(TaskEditPage::class, ['task' => $schedule->id()]), |
|
| 75 | + 'task_status_route' => route(TaskStatusAction::class, [ |
|
| 76 | + 'task' => $schedule->id(), |
|
| 77 | + 'enable' => $schedule->isEnabled() ? 0 : 1 |
|
| 78 | + ]) |
|
| 79 | + ]), |
|
| 80 | + 'status' => [ |
|
| 81 | + 'display' => view($module_name . '::components/yes-no-icons', [ |
|
| 82 | + 'yes' => $schedule->isEnabled() |
|
| 83 | + ]), |
|
| 84 | + 'raw' => $schedule->isEnabled() ? 1 : 0 |
|
| 85 | + ], |
|
| 86 | + 'task_name' => [ |
|
| 87 | + 'display' => '<bdi>' . e($task_name) . '</bdi>', |
|
| 88 | + 'raw' => $task_name |
|
| 89 | + ], |
|
| 90 | + 'last_run' => [ |
|
| 91 | + 'display' => $last_run_timestamp->timestamp() === 0 ? |
|
| 92 | + view('components/datetime', ['timestamp' => $last_run_timestamp]) : |
|
| 93 | + view('components/datetime-diff', ['timestamp' => $last_run_timestamp]), |
|
| 94 | + 'raw' => $schedule->lastRunTime()->getTimestamp() |
|
| 95 | + ], |
|
| 96 | + 'last_result' => [ |
|
| 97 | + 'display' => view($module_name . '::components/yes-no-icons', [ |
|
| 98 | + 'yes' => $schedule->wasLastRunSuccess() |
|
| 99 | + ]), |
|
| 100 | + 'raw' => $schedule->wasLastRunSuccess() ? 1 : 0 |
|
| 101 | + ], |
|
| 102 | + 'frequency' => |
|
| 103 | + '<bdi>' . e(CarbonInterval::minutes($schedule->frequency())->cascade()->forHumans()) . '</bdi>', |
|
| 104 | + 'nb_occurrences' => $schedule->remainingOccurrences() > 0 ? |
|
| 105 | + I18N::number($schedule->remainingOccurrences()) : |
|
| 106 | + I18N::translate('Unlimited'), |
|
| 107 | + 'running' => view($module_name . '::components/yes-no-icons', [ |
|
| 108 | + 'yes' => $schedule->isRunning(), |
|
| 109 | + 'text_yes' => I18N::translate('Running'), |
|
| 110 | + 'text_no' => I18N::translate('Not running') |
|
| 111 | + ]), |
|
| 112 | + 'run' => view($module_name . '::admin/tasks-table-run', [ |
|
| 113 | + 'task_sched_id' => $schedule->id(), |
|
| 114 | + 'run_route' => route(TaskTrigger::class, [ |
|
| 115 | + 'task' => $schedule->taskId(), |
|
| 116 | + 'force' => $module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN') |
|
| 117 | + ]) |
|
| 118 | + ]) |
|
| 119 | + ]; |
|
| 120 | + }) |
|
| 121 | + ]); |
|
| 122 | + } |
|
| 123 | 123 | } |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | $module = $this->module; |
| 63 | 63 | $module_name = $this->module->name(); |
| 64 | 64 | return Registry::responseFactory()->response(['data' => $this->taskschedules_service->all(true, true) |
| 65 | - ->map(function (TaskSchedule $schedule) use ($module, $module_name): array { |
|
| 65 | + ->map(function(TaskSchedule $schedule) use ($module, $module_name): array { |
|
| 66 | 66 | $task = $this->taskschedules_service->findTask($schedule->taskId()); |
| 67 | 67 | $task_name = $task !== null ? $task->name() : I18N::translate('Task not found'); |
| 68 | 68 | $last_run_timestamp = Registry::timestampFactory()->make($schedule->lastRunTime()->getTimestamp()); |
| 69 | 69 | |
| 70 | 70 | return [ |
| 71 | - 'edit' => view($module_name . '::admin/tasks-table-options', [ |
|
| 71 | + 'edit' => view($module_name.'::admin/tasks-table-options', [ |
|
| 72 | 72 | 'task_sched_id' => $schedule->id(), |
| 73 | 73 | 'task_sched_enabled' => $schedule->isEnabled(), |
| 74 | 74 | 'task_edit_route' => route(TaskEditPage::class, ['task' => $schedule->id()]), |
@@ -78,38 +78,36 @@ discard block |
||
| 78 | 78 | ]) |
| 79 | 79 | ]), |
| 80 | 80 | 'status' => [ |
| 81 | - 'display' => view($module_name . '::components/yes-no-icons', [ |
|
| 81 | + 'display' => view($module_name.'::components/yes-no-icons', [ |
|
| 82 | 82 | 'yes' => $schedule->isEnabled() |
| 83 | 83 | ]), |
| 84 | 84 | 'raw' => $schedule->isEnabled() ? 1 : 0 |
| 85 | 85 | ], |
| 86 | 86 | 'task_name' => [ |
| 87 | - 'display' => '<bdi>' . e($task_name) . '</bdi>', |
|
| 87 | + 'display' => '<bdi>'.e($task_name).'</bdi>', |
|
| 88 | 88 | 'raw' => $task_name |
| 89 | 89 | ], |
| 90 | 90 | 'last_run' => [ |
| 91 | 91 | 'display' => $last_run_timestamp->timestamp() === 0 ? |
| 92 | - view('components/datetime', ['timestamp' => $last_run_timestamp]) : |
|
| 93 | - view('components/datetime-diff', ['timestamp' => $last_run_timestamp]), |
|
| 92 | + view('components/datetime', ['timestamp' => $last_run_timestamp]) : view('components/datetime-diff', ['timestamp' => $last_run_timestamp]), |
|
| 94 | 93 | 'raw' => $schedule->lastRunTime()->getTimestamp() |
| 95 | 94 | ], |
| 96 | 95 | 'last_result' => [ |
| 97 | - 'display' => view($module_name . '::components/yes-no-icons', [ |
|
| 96 | + 'display' => view($module_name.'::components/yes-no-icons', [ |
|
| 98 | 97 | 'yes' => $schedule->wasLastRunSuccess() |
| 99 | 98 | ]), |
| 100 | 99 | 'raw' => $schedule->wasLastRunSuccess() ? 1 : 0 |
| 101 | 100 | ], |
| 102 | 101 | 'frequency' => |
| 103 | - '<bdi>' . e(CarbonInterval::minutes($schedule->frequency())->cascade()->forHumans()) . '</bdi>', |
|
| 102 | + '<bdi>'.e(CarbonInterval::minutes($schedule->frequency())->cascade()->forHumans()).'</bdi>', |
|
| 104 | 103 | 'nb_occurrences' => $schedule->remainingOccurrences() > 0 ? |
| 105 | - I18N::number($schedule->remainingOccurrences()) : |
|
| 106 | - I18N::translate('Unlimited'), |
|
| 107 | - 'running' => view($module_name . '::components/yes-no-icons', [ |
|
| 104 | + I18N::number($schedule->remainingOccurrences()) : I18N::translate('Unlimited'), |
|
| 105 | + 'running' => view($module_name.'::components/yes-no-icons', [ |
|
| 108 | 106 | 'yes' => $schedule->isRunning(), |
| 109 | 107 | 'text_yes' => I18N::translate('Running'), |
| 110 | 108 | 'text_no' => I18N::translate('Not running') |
| 111 | 109 | ]), |
| 112 | - 'run' => view($module_name . '::admin/tasks-table-run', [ |
|
| 110 | + 'run' => view($module_name.'::admin/tasks-table-run', [ |
|
| 113 | 111 | 'task_sched_id' => $schedule->id(), |
| 114 | 112 | 'run_route' => route(TaskTrigger::class, [ |
| 115 | 113 | 'task' => $schedule->taskId(), |
@@ -30,41 +30,41 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class TaskTrigger implements RequestHandlerInterface |
| 32 | 32 | { |
| 33 | - private ?AdminTasksModule $module; |
|
| 34 | - private TaskScheduleService $taskschedules_service; |
|
| 33 | + private ?AdminTasksModule $module; |
|
| 34 | + private TaskScheduleService $taskschedules_service; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Constructor for TaskTrigger request handler |
|
| 38 | - * @param ModuleService $module_service |
|
| 39 | - * @param TaskScheduleService $taskschedules_service |
|
| 40 | - */ |
|
| 41 | - public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service) |
|
| 42 | - { |
|
| 43 | - $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
| 44 | - $this->taskschedules_service = $taskschedules_service; |
|
| 45 | - } |
|
| 36 | + /** |
|
| 37 | + * Constructor for TaskTrigger request handler |
|
| 38 | + * @param ModuleService $module_service |
|
| 39 | + * @param TaskScheduleService $taskschedules_service |
|
| 40 | + */ |
|
| 41 | + public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service) |
|
| 42 | + { |
|
| 43 | + $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
| 44 | + $this->taskschedules_service = $taskschedules_service; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * {@inheritDoc} |
|
| 49 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 50 | - */ |
|
| 51 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 52 | - { |
|
| 53 | - if ($this->module === null) { |
|
| 54 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 55 | - } |
|
| 47 | + /** |
|
| 48 | + * {@inheritDoc} |
|
| 49 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 50 | + */ |
|
| 51 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 52 | + { |
|
| 53 | + if ($this->module === null) { |
|
| 54 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - $task_id = Validator::attributes($request)->string('task', ''); |
|
| 58 | - $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN'); |
|
| 59 | - $force_token = Validator::queryParams($request)->string('force', ''); |
|
| 60 | - $force = $token !== '' && $token === $force_token; |
|
| 57 | + $task_id = Validator::attributes($request)->string('task', ''); |
|
| 58 | + $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN'); |
|
| 59 | + $force_token = Validator::queryParams($request)->string('force', ''); |
|
| 60 | + $force = $token !== '' && $token === $force_token; |
|
| 61 | 61 | |
| 62 | - $task_schedules = $this->taskschedules_service->findTasksToRun($force, $task_id); |
|
| 62 | + $task_schedules = $this->taskschedules_service->findTasksToRun($force, $task_id); |
|
| 63 | 63 | |
| 64 | - foreach ($task_schedules as $task_schedule) { |
|
| 65 | - $this->taskschedules_service->run($task_schedule, $force); |
|
| 66 | - } |
|
| 64 | + foreach ($task_schedules as $task_schedule) { |
|
| 65 | + $this->taskschedules_service->run($task_schedule, $force); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - return Registry::responseFactory()->response(); |
|
| 69 | - } |
|
| 68 | + return Registry::responseFactory()->response(); |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | $task_id = Validator::attributes($request)->string('task', ''); |
| 58 | 58 | $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN'); |
| 59 | 59 | $force_token = Validator::queryParams($request)->string('force', ''); |
| 60 | - $force = $token !== '' && $token === $force_token; |
|
| 60 | + $force = $token !== '' && $token === $force_token; |
|
| 61 | 61 | |
| 62 | 62 | $task_schedules = $this->taskschedules_service->findTasksToRun($force, $task_id); |
| 63 | 63 | |