@@ -25,117 +25,117 @@ |
||
25 | 25 | class LineageNode |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var Collection $linked_fams Spouse families linked to the node |
|
30 | - */ |
|
31 | - private $linked_fams; |
|
28 | + /** |
|
29 | + * @var Collection $linked_fams Spouse families linked to the node |
|
30 | + */ |
|
31 | + private $linked_fams; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var ?Individual $node_indi Reference individual for the node |
|
35 | - */ |
|
36 | - private $node_indi; |
|
33 | + /** |
|
34 | + * @var ?Individual $node_indi Reference individual for the node |
|
35 | + */ |
|
36 | + private $node_indi; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var LineageRootNode $root_node Root node of the lineage |
|
40 | - */ |
|
41 | - private $root_node; |
|
38 | + /** |
|
39 | + * @var LineageRootNode $root_node Root node of the lineage |
|
40 | + */ |
|
41 | + private $root_node; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var ?string $alt_surname Linked surname, used to link to another lineage |
|
45 | - */ |
|
46 | - private $alt_surname; |
|
43 | + /** |
|
44 | + * @var ?string $alt_surname Linked surname, used to link to another lineage |
|
45 | + */ |
|
46 | + private $alt_surname; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Constructor for Lineage node |
|
50 | - * |
|
51 | - * @param Individual $node_indi Main individual |
|
52 | - * @param LineageRootNode $root_node Node of the lineage root |
|
53 | - * @param null|string $alt_surname Follow-up surname |
|
54 | - */ |
|
55 | - public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null) |
|
56 | - { |
|
57 | - $this->node_indi = $node_indi; |
|
58 | - $this->root_node = $root_node; |
|
59 | - $this->alt_surname = $alt_surname; |
|
60 | - $this->linked_fams = new Collection(); |
|
61 | - } |
|
48 | + /** |
|
49 | + * Constructor for Lineage node |
|
50 | + * |
|
51 | + * @param Individual $node_indi Main individual |
|
52 | + * @param LineageRootNode $root_node Node of the lineage root |
|
53 | + * @param null|string $alt_surname Follow-up surname |
|
54 | + */ |
|
55 | + public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null) |
|
56 | + { |
|
57 | + $this->node_indi = $node_indi; |
|
58 | + $this->root_node = $root_node; |
|
59 | + $this->alt_surname = $alt_surname; |
|
60 | + $this->linked_fams = new Collection(); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Add a spouse family to the node |
|
65 | - * |
|
66 | - * @param Family $fams |
|
67 | - * @return stdClass |
|
68 | - */ |
|
69 | - public function addFamily(Family $fams): object |
|
70 | - { |
|
71 | - if (!$this->linked_fams->has($fams->xref())) { |
|
72 | - $this->linked_fams->put($fams->xref(), (object) [ |
|
73 | - 'family' => $fams, |
|
74 | - 'children' => new Collection() |
|
75 | - ]); |
|
76 | - } |
|
77 | - return $this->linked_fams->get($fams->xref()); |
|
78 | - } |
|
63 | + /** |
|
64 | + * Add a spouse family to the node |
|
65 | + * |
|
66 | + * @param Family $fams |
|
67 | + * @return stdClass |
|
68 | + */ |
|
69 | + public function addFamily(Family $fams): object |
|
70 | + { |
|
71 | + if (!$this->linked_fams->has($fams->xref())) { |
|
72 | + $this->linked_fams->put($fams->xref(), (object) [ |
|
73 | + 'family' => $fams, |
|
74 | + 'children' => new Collection() |
|
75 | + ]); |
|
76 | + } |
|
77 | + return $this->linked_fams->get($fams->xref()); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Add a child LineageNode to the node |
|
82 | - * |
|
83 | - * @param Family $fams |
|
84 | - * @param LineageNode $child |
|
85 | - */ |
|
86 | - public function addChild(Family $fams, LineageNode $child = null): void |
|
87 | - { |
|
88 | - $this->addFamily($fams)->children->push($child); |
|
89 | - $this->root_node->incrementChildNodes(); |
|
90 | - } |
|
80 | + /** |
|
81 | + * Add a child LineageNode to the node |
|
82 | + * |
|
83 | + * @param Family $fams |
|
84 | + * @param LineageNode $child |
|
85 | + */ |
|
86 | + public function addChild(Family $fams, LineageNode $child = null): void |
|
87 | + { |
|
88 | + $this->addFamily($fams)->children->push($child); |
|
89 | + $this->root_node->incrementChildNodes(); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Returns the node individual |
|
94 | - * |
|
95 | - * @return Individual|NULL |
|
96 | - */ |
|
97 | - public function individual(): ?Individual |
|
98 | - { |
|
99 | - return $this->node_indi; |
|
100 | - } |
|
92 | + /** |
|
93 | + * Returns the node individual |
|
94 | + * |
|
95 | + * @return Individual|NULL |
|
96 | + */ |
|
97 | + public function individual(): ?Individual |
|
98 | + { |
|
99 | + return $this->node_indi; |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Returns the lineage root node individual |
|
104 | - * |
|
105 | - * @return LineageRootNode |
|
106 | - */ |
|
107 | - public function rootNode(): LineageRootNode |
|
108 | - { |
|
109 | - return $this->root_node; |
|
110 | - } |
|
102 | + /** |
|
103 | + * Returns the lineage root node individual |
|
104 | + * |
|
105 | + * @return LineageRootNode |
|
106 | + */ |
|
107 | + public function rootNode(): LineageRootNode |
|
108 | + { |
|
109 | + return $this->root_node; |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * Returns the spouse families linked to the node |
|
114 | - * |
|
115 | - * @return Collection |
|
116 | - */ |
|
117 | - public function families(): Collection |
|
118 | - { |
|
119 | - return $this->linked_fams; |
|
120 | - } |
|
112 | + /** |
|
113 | + * Returns the spouse families linked to the node |
|
114 | + * |
|
115 | + * @return Collection |
|
116 | + */ |
|
117 | + public function families(): Collection |
|
118 | + { |
|
119 | + return $this->linked_fams; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Returns the follow-up surname |
|
124 | - * |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - public function followUpSurname(): string |
|
128 | - { |
|
129 | - return $this->alt_surname ?? ''; |
|
130 | - } |
|
122 | + /** |
|
123 | + * Returns the follow-up surname |
|
124 | + * |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + public function followUpSurname(): string |
|
128 | + { |
|
129 | + return $this->alt_surname ?? ''; |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Indicates whether the node has a follow up surname |
|
134 | - * |
|
135 | - * @return boolean |
|
136 | - */ |
|
137 | - public function hasFollowUpSurname(): bool |
|
138 | - { |
|
139 | - return mb_strlen($this->followUpSurname()) > 0 ; |
|
140 | - } |
|
132 | + /** |
|
133 | + * Indicates whether the node has a follow up surname |
|
134 | + * |
|
135 | + * @return boolean |
|
136 | + */ |
|
137 | + public function hasFollowUpSurname(): bool |
|
138 | + { |
|
139 | + return mb_strlen($this->followUpSurname()) > 0 ; |
|
140 | + } |
|
141 | 141 | } |
@@ -31,66 +31,66 @@ |
||
31 | 31 | */ |
32 | 32 | class LineagesPage implements RequestHandlerInterface |
33 | 33 | { |
34 | - use ViewResponseTrait; |
|
34 | + use ViewResponseTrait; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var PatronymicLineageModule $module |
|
38 | - */ |
|
39 | - private $module; |
|
36 | + /** |
|
37 | + * @var PatronymicLineageModule $module |
|
38 | + */ |
|
39 | + private $module; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var IndividualListService $indilist_service |
|
43 | - */ |
|
44 | - private $indilist_service; |
|
41 | + /** |
|
42 | + * @var IndividualListService $indilist_service |
|
43 | + */ |
|
44 | + private $indilist_service; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Constructor for LineagesPage Request handler |
|
48 | - * |
|
49 | - * @param ModuleService $module_service |
|
50 | - * @param IndividualListService $indilist_service |
|
51 | - */ |
|
52 | - public function __construct(ModuleService $module_service, IndividualListService $indilist_service) |
|
53 | - { |
|
54 | - $this->module = $module_service->findByInterface(PatronymicLineageModule::class)->first(); |
|
55 | - $this->indilist_service = $indilist_service; |
|
56 | - } |
|
46 | + /** |
|
47 | + * Constructor for LineagesPage Request handler |
|
48 | + * |
|
49 | + * @param ModuleService $module_service |
|
50 | + * @param IndividualListService $indilist_service |
|
51 | + */ |
|
52 | + public function __construct(ModuleService $module_service, IndividualListService $indilist_service) |
|
53 | + { |
|
54 | + $this->module = $module_service->findByInterface(PatronymicLineageModule::class)->first(); |
|
55 | + $this->indilist_service = $indilist_service; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * {@inheritDoc} |
|
60 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
61 | - */ |
|
62 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
63 | - { |
|
64 | - if ($this->module === null) { |
|
65 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
66 | - } |
|
58 | + /** |
|
59 | + * {@inheritDoc} |
|
60 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
61 | + */ |
|
62 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
63 | + { |
|
64 | + if ($this->module === null) { |
|
65 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
66 | + } |
|
67 | 67 | |
68 | - $tree = $request->getAttribute('tree'); |
|
69 | - assert($tree instanceof Tree); |
|
68 | + $tree = $request->getAttribute('tree'); |
|
69 | + assert($tree instanceof Tree); |
|
70 | 70 | |
71 | - $surname = $request->getAttribute('surname'); |
|
71 | + $surname = $request->getAttribute('surname'); |
|
72 | 72 | |
73 | - $initial = mb_substr($surname, 0, 1); |
|
74 | - $initials_list = collect($this->indilist_service->surnameAlpha(false, false, I18N::locale())) |
|
75 | - ->reject(function ($count, $initial) { |
|
73 | + $initial = mb_substr($surname, 0, 1); |
|
74 | + $initials_list = collect($this->indilist_service->surnameAlpha(false, false, I18N::locale())) |
|
75 | + ->reject(function ($count, $initial) { |
|
76 | 76 | |
77 | - return $initial === '@' || $initial === ','; |
|
78 | - }); |
|
77 | + return $initial === '@' || $initial === ','; |
|
78 | + }); |
|
79 | 79 | |
80 | - $title = I18N::translate('Patronymic Lineages') . ' — ' . $surname; |
|
80 | + $title = I18N::translate('Patronymic Lineages') . ' — ' . $surname; |
|
81 | 81 | |
82 | - $lineages = app()->make(LineageBuilder::class, ['surname' => $surname])->buildLineages(); |
|
82 | + $lineages = app()->make(LineageBuilder::class, ['surname' => $surname])->buildLineages(); |
|
83 | 83 | |
84 | - return $this->viewResponse($this->module->name() . '::lineages-page', [ |
|
85 | - 'title' => $title, |
|
86 | - 'module' => $this->module, |
|
87 | - 'tree' => $tree, |
|
88 | - 'initials_list' => $initials_list, |
|
89 | - 'initial' => $initial, |
|
90 | - 'show_all' => 'no', |
|
91 | - 'surname' => $surname, |
|
92 | - 'lineages' => $lineages, |
|
93 | - 'nb_lineages' => $lineages !== null ? $lineages->count() : 0 |
|
94 | - ]); |
|
95 | - } |
|
84 | + return $this->viewResponse($this->module->name() . '::lineages-page', [ |
|
85 | + 'title' => $title, |
|
86 | + 'module' => $this->module, |
|
87 | + 'tree' => $tree, |
|
88 | + 'initials_list' => $initials_list, |
|
89 | + 'initial' => $initial, |
|
90 | + 'show_all' => 'no', |
|
91 | + 'surname' => $surname, |
|
92 | + 'lineages' => $lineages, |
|
93 | + 'nb_lineages' => $lineages !== null ? $lineages->count() : 0 |
|
94 | + ]); |
|
95 | + } |
|
96 | 96 | } |
@@ -20,11 +20,11 @@ |
||
20 | 20 | interface ModuleTasksProviderInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * List tasks provided by the module as an associative array. |
|
25 | - * They keys are used as task IDs for storage and reference. |
|
26 | - * |
|
27 | - * @return array<string, string> List of tasks |
|
28 | - */ |
|
29 | - public function listTasks(): array; |
|
23 | + /** |
|
24 | + * List tasks provided by the module as an associative array. |
|
25 | + * They keys are used as task IDs for storage and reference. |
|
26 | + * |
|
27 | + * @return array<string, string> List of tasks |
|
28 | + */ |
|
29 | + public function listTasks(): array; |
|
30 | 30 | } |
@@ -31,65 +31,65 @@ |
||
31 | 31 | */ |
32 | 32 | class TaskEditPage implements RequestHandlerInterface |
33 | 33 | { |
34 | - use ViewResponseTrait; |
|
34 | + use ViewResponseTrait; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var AdminTasksModule $module |
|
38 | - */ |
|
39 | - private $module; |
|
36 | + /** |
|
37 | + * @var AdminTasksModule $module |
|
38 | + */ |
|
39 | + private $module; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var TaskScheduleService $taskschedules_service |
|
43 | - */ |
|
44 | - private $taskschedules_service; |
|
41 | + /** |
|
42 | + * @var TaskScheduleService $taskschedules_service |
|
43 | + */ |
|
44 | + private $taskschedules_service; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Constructor for TaskEditPage Request Handler |
|
48 | - * |
|
49 | - * @param ModuleService $module_service |
|
50 | - * @param TaskScheduleService $taskschedules_service |
|
51 | - */ |
|
52 | - public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service) |
|
53 | - { |
|
54 | - $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
55 | - $this->taskschedules_service = $taskschedules_service; |
|
56 | - } |
|
46 | + /** |
|
47 | + * Constructor for TaskEditPage Request Handler |
|
48 | + * |
|
49 | + * @param ModuleService $module_service |
|
50 | + * @param TaskScheduleService $taskschedules_service |
|
51 | + */ |
|
52 | + public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service) |
|
53 | + { |
|
54 | + $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
55 | + $this->taskschedules_service = $taskschedules_service; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * {@inheritDoc} |
|
60 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
61 | - */ |
|
62 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
63 | - { |
|
64 | - $this->layout = 'layouts/administration'; |
|
58 | + /** |
|
59 | + * {@inheritDoc} |
|
60 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
61 | + */ |
|
62 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
63 | + { |
|
64 | + $this->layout = 'layouts/administration'; |
|
65 | 65 | |
66 | - if ($this->module === null) { |
|
67 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
68 | - } |
|
66 | + if ($this->module === null) { |
|
67 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
68 | + } |
|
69 | 69 | |
70 | - $task_sched_id = (int) $request->getAttribute('task'); |
|
71 | - $task_schedule = $this->taskschedules_service->find($task_sched_id); |
|
70 | + $task_sched_id = (int) $request->getAttribute('task'); |
|
71 | + $task_schedule = $this->taskschedules_service->find($task_sched_id); |
|
72 | 72 | |
73 | - if ($task_schedule === null) { |
|
74 | - throw new HttpNotFoundException(I18N::translate('The Task schedule could not be found.')); |
|
75 | - } |
|
73 | + if ($task_schedule === null) { |
|
74 | + throw new HttpNotFoundException(I18N::translate('The Task schedule could not be found.')); |
|
75 | + } |
|
76 | 76 | |
77 | - $task = $this->taskschedules_service->findTask($task_schedule->taskId()); |
|
77 | + $task = $this->taskschedules_service->findTask($task_schedule->taskId()); |
|
78 | 78 | |
79 | - if ($task === null) { |
|
80 | - throw new HttpNotFoundException(I18N::translate('The Task schedule could not be found.')); |
|
81 | - } |
|
79 | + if ($task === null) { |
|
80 | + throw new HttpNotFoundException(I18N::translate('The Task schedule could not be found.')); |
|
81 | + } |
|
82 | 82 | |
83 | - /** @var TaskInterface&ConfigurableTaskInterface $task */ |
|
84 | - $has_task_config = $task instanceof ConfigurableTaskInterface; |
|
83 | + /** @var TaskInterface&ConfigurableTaskInterface $task */ |
|
84 | + $has_task_config = $task instanceof ConfigurableTaskInterface; |
|
85 | 85 | |
86 | - return $this->viewResponse($this->module->name() . '::admin/tasks-edit', [ |
|
87 | - 'module' => $this->module, |
|
88 | - 'title' => I18N::translate('Edit the administrative task') . ' - ' . $task->name(), |
|
89 | - 'task_schedule' => $task_schedule, |
|
90 | - 'task' => $task, |
|
91 | - 'has_task_config' => $has_task_config, |
|
92 | - 'task_config_view' => $has_task_config ? '' : $task->configView($request) |
|
93 | - ]); |
|
94 | - } |
|
86 | + return $this->viewResponse($this->module->name() . '::admin/tasks-edit', [ |
|
87 | + 'module' => $this->module, |
|
88 | + 'title' => I18N::translate('Edit the administrative task') . ' - ' . $task->name(), |
|
89 | + 'task_schedule' => $task_schedule, |
|
90 | + 'task' => $task, |
|
91 | + 'has_task_config' => $has_task_config, |
|
92 | + 'task_config_view' => $has_task_config ? '' : $task->configView($request) |
|
93 | + ]); |
|
94 | + } |
|
95 | 95 | } |
@@ -34,142 +34,142 @@ |
||
34 | 34 | */ |
35 | 35 | class TaskEditAction implements RequestHandlerInterface |
36 | 36 | { |
37 | - /** |
|
38 | - * @var AdminTasksModule $module |
|
39 | - */ |
|
40 | - private $module; |
|
37 | + /** |
|
38 | + * @var AdminTasksModule $module |
|
39 | + */ |
|
40 | + private $module; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @var TaskScheduleService $taskschedules_service |
|
44 | - */ |
|
45 | - private $taskschedules_service; |
|
42 | + /** |
|
43 | + * @var TaskScheduleService $taskschedules_service |
|
44 | + */ |
|
45 | + private $taskschedules_service; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Constructor for TaskEditAction Request Handler |
|
49 | - * |
|
50 | - * @param ModuleService $module_service |
|
51 | - * @param TaskScheduleService $taskschedules_service |
|
52 | - */ |
|
53 | - public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service) |
|
54 | - { |
|
55 | - $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
56 | - $this->taskschedules_service = $taskschedules_service; |
|
57 | - } |
|
47 | + /** |
|
48 | + * Constructor for TaskEditAction Request Handler |
|
49 | + * |
|
50 | + * @param ModuleService $module_service |
|
51 | + * @param TaskScheduleService $taskschedules_service |
|
52 | + */ |
|
53 | + public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service) |
|
54 | + { |
|
55 | + $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
56 | + $this->taskschedules_service = $taskschedules_service; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * {@inheritDoc} |
|
61 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
62 | - */ |
|
63 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
64 | - { |
|
65 | - $task_sched_id = (int) $request->getAttribute('task'); |
|
66 | - $task_schedule = $this->taskschedules_service->find($task_sched_id); |
|
59 | + /** |
|
60 | + * {@inheritDoc} |
|
61 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
62 | + */ |
|
63 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
64 | + { |
|
65 | + $task_sched_id = (int) $request->getAttribute('task'); |
|
66 | + $task_schedule = $this->taskschedules_service->find($task_sched_id); |
|
67 | 67 | |
68 | - $admin_config_route = route(AdminConfigPage::class); |
|
68 | + $admin_config_route = route(AdminConfigPage::class); |
|
69 | 69 | |
70 | - if ($task_schedule === null) { |
|
71 | - FlashMessages::addMessage( |
|
72 | - I18N::translate('The task shedule with ID “%d” does not exist.', I18N::number($task_sched_id)), |
|
73 | - 'danger' |
|
74 | - ); |
|
75 | - return redirect($admin_config_route); |
|
76 | - } |
|
70 | + if ($task_schedule === null) { |
|
71 | + FlashMessages::addMessage( |
|
72 | + I18N::translate('The task shedule with ID “%d” does not exist.', I18N::number($task_sched_id)), |
|
73 | + 'danger' |
|
74 | + ); |
|
75 | + return redirect($admin_config_route); |
|
76 | + } |
|
77 | 77 | |
78 | - $success = $this->updateGeneralSettings($task_schedule, $request); |
|
79 | - $success = $success && $this->updateSpecificSettings($task_schedule, $request); |
|
78 | + $success = $this->updateGeneralSettings($task_schedule, $request); |
|
79 | + $success = $success && $this->updateSpecificSettings($task_schedule, $request); |
|
80 | 80 | |
81 | - if ($success) { |
|
82 | - FlashMessages::addMessage( |
|
83 | - I18N::translate('The scheduled task has been successfully updated'), |
|
84 | - 'success' |
|
85 | - ); |
|
86 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
87 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.'); |
|
88 | - } |
|
81 | + if ($success) { |
|
82 | + FlashMessages::addMessage( |
|
83 | + I18N::translate('The scheduled task has been successfully updated'), |
|
84 | + 'success' |
|
85 | + ); |
|
86 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
87 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.'); |
|
88 | + } |
|
89 | 89 | |
90 | - return redirect($admin_config_route); |
|
91 | - } |
|
90 | + return redirect($admin_config_route); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Update general settings for the task, based on the request parameters |
|
95 | - * |
|
96 | - * @param TaskSchedule $task_schedule |
|
97 | - * @param ServerRequestInterface $request |
|
98 | - * @return bool |
|
99 | - */ |
|
100 | - private function updateGeneralSettings(TaskSchedule $task_schedule, ServerRequestInterface $request): bool |
|
101 | - { |
|
102 | - $params = (array) $request->getParsedBody(); |
|
93 | + /** |
|
94 | + * Update general settings for the task, based on the request parameters |
|
95 | + * |
|
96 | + * @param TaskSchedule $task_schedule |
|
97 | + * @param ServerRequestInterface $request |
|
98 | + * @return bool |
|
99 | + */ |
|
100 | + private function updateGeneralSettings(TaskSchedule $task_schedule, ServerRequestInterface $request): bool |
|
101 | + { |
|
102 | + $params = (array) $request->getParsedBody(); |
|
103 | 103 | |
104 | - $frequency = (int) $params['frequency']; |
|
105 | - if ($frequency > 0) { |
|
106 | - $task_schedule->setFrequency(CarbonInterval::minutes($frequency)); |
|
107 | - } else { |
|
108 | - FlashMessages::addMessage(I18N::translate('The frequency is not in a valid format'), 'danger'); |
|
109 | - } |
|
104 | + $frequency = (int) $params['frequency']; |
|
105 | + if ($frequency > 0) { |
|
106 | + $task_schedule->setFrequency(CarbonInterval::minutes($frequency)); |
|
107 | + } else { |
|
108 | + FlashMessages::addMessage(I18N::translate('The frequency is not in a valid format'), 'danger'); |
|
109 | + } |
|
110 | 110 | |
111 | - $is_limited = (bool) $params['is_limited']; |
|
112 | - $nb_occur = (int) $params['nb_occur']; |
|
111 | + $is_limited = (bool) $params['is_limited']; |
|
112 | + $nb_occur = (int) $params['nb_occur']; |
|
113 | 113 | |
114 | - if ($is_limited) { |
|
115 | - if ($nb_occur > 0) { |
|
116 | - $task_schedule->setRemainingOccurences($nb_occur); |
|
117 | - } else { |
|
118 | - FlashMessages::addMessage( |
|
119 | - I18N::translate('The number of remaining occurences is not in a valid format'), |
|
120 | - 'danger' |
|
121 | - ); |
|
122 | - } |
|
123 | - } else { |
|
124 | - $task_schedule->setRemainingOccurences(0); |
|
125 | - } |
|
114 | + if ($is_limited) { |
|
115 | + if ($nb_occur > 0) { |
|
116 | + $task_schedule->setRemainingOccurences($nb_occur); |
|
117 | + } else { |
|
118 | + FlashMessages::addMessage( |
|
119 | + I18N::translate('The number of remaining occurences is not in a valid format'), |
|
120 | + 'danger' |
|
121 | + ); |
|
122 | + } |
|
123 | + } else { |
|
124 | + $task_schedule->setRemainingOccurences(0); |
|
125 | + } |
|
126 | 126 | |
127 | - try { |
|
128 | - $this->taskschedules_service->update($task_schedule); |
|
129 | - return true; |
|
130 | - } catch (Exception $ex) { |
|
131 | - Log::addErrorLog( |
|
132 | - sprintf( |
|
133 | - 'Error while updating the Task Schedule "%s". Exception: %s', |
|
134 | - $task_schedule->id(), |
|
135 | - $ex->getMessage() |
|
136 | - ) |
|
137 | - ); |
|
138 | - } |
|
127 | + try { |
|
128 | + $this->taskschedules_service->update($task_schedule); |
|
129 | + return true; |
|
130 | + } catch (Exception $ex) { |
|
131 | + Log::addErrorLog( |
|
132 | + sprintf( |
|
133 | + 'Error while updating the Task Schedule "%s". Exception: %s', |
|
134 | + $task_schedule->id(), |
|
135 | + $ex->getMessage() |
|
136 | + ) |
|
137 | + ); |
|
138 | + } |
|
139 | 139 | |
140 | - FlashMessages::addMessage(I18N::translate('An error occured while updating the scheduled task'), 'danger'); |
|
141 | - //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
142 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.'); |
|
143 | - return false; |
|
144 | - } |
|
140 | + FlashMessages::addMessage(I18N::translate('An error occured while updating the scheduled task'), 'danger'); |
|
141 | + //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
142 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.'); |
|
143 | + return false; |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * Update general settings for the task, based on the request parameters |
|
148 | - * |
|
149 | - * @param TaskSchedule $task_schedule |
|
150 | - * @param ServerRequestInterface $request |
|
151 | - * @return bool |
|
152 | - */ |
|
153 | - private function updateSpecificSettings(TaskSchedule $task_schedule, ServerRequestInterface $request): bool |
|
154 | - { |
|
155 | - $task = $this->taskschedules_service->findTask($task_schedule->taskId()); |
|
156 | - if ($task === null || !($task instanceof ConfigurableTaskInterface)) { |
|
157 | - return true; |
|
158 | - } |
|
146 | + /** |
|
147 | + * Update general settings for the task, based on the request parameters |
|
148 | + * |
|
149 | + * @param TaskSchedule $task_schedule |
|
150 | + * @param ServerRequestInterface $request |
|
151 | + * @return bool |
|
152 | + */ |
|
153 | + private function updateSpecificSettings(TaskSchedule $task_schedule, ServerRequestInterface $request): bool |
|
154 | + { |
|
155 | + $task = $this->taskschedules_service->findTask($task_schedule->taskId()); |
|
156 | + if ($task === null || !($task instanceof ConfigurableTaskInterface)) { |
|
157 | + return true; |
|
158 | + } |
|
159 | 159 | |
160 | - /** @var TaskInterface&ConfigurableTaskInterface $task */ |
|
161 | - if (!$task->updateConfig($request, $task_schedule)) { |
|
162 | - FlashMessages::addMessage( |
|
163 | - I18N::translate( |
|
164 | - 'An error occured while updating the specific settings of administrative task “%s”', |
|
165 | - $task->name() |
|
166 | - ), |
|
167 | - 'danger' |
|
168 | - ); |
|
169 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
170 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : AdminTask “' . $task->name() . '” specific settings could not be updated. See error log.'); |
|
171 | - } |
|
160 | + /** @var TaskInterface&ConfigurableTaskInterface $task */ |
|
161 | + if (!$task->updateConfig($request, $task_schedule)) { |
|
162 | + FlashMessages::addMessage( |
|
163 | + I18N::translate( |
|
164 | + 'An error occured while updating the specific settings of administrative task “%s”', |
|
165 | + $task->name() |
|
166 | + ), |
|
167 | + 'danger' |
|
168 | + ); |
|
169 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
170 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : AdminTask “' . $task->name() . '” specific settings could not be updated. See error log.'); |
|
171 | + } |
|
172 | 172 | |
173 | - return true; |
|
174 | - } |
|
173 | + return true; |
|
174 | + } |
|
175 | 175 | } |
@@ -40,125 +40,125 @@ |
||
40 | 40 | * Allow for tasks to be run on a (nearly-)regular schedule |
41 | 41 | */ |
42 | 42 | class AdminTasksModule extends AbstractModuleMaj implements |
43 | - ModuleCustomInterface, |
|
44 | - ModuleConfigInterface, |
|
45 | - ModuleGlobalInterface, |
|
46 | - ModuleTasksProviderInterface |
|
43 | + ModuleCustomInterface, |
|
44 | + ModuleConfigInterface, |
|
45 | + ModuleGlobalInterface, |
|
46 | + ModuleTasksProviderInterface |
|
47 | 47 | { |
48 | - use ModuleConfigTrait; |
|
49 | - use ModuleGlobalTrait; |
|
48 | + use ModuleConfigTrait; |
|
49 | + use ModuleGlobalTrait; |
|
50 | 50 | |
51 | - //How to update the database schema for this module |
|
52 | - private const SCHEMA_TARGET_VERSION = 2; |
|
53 | - private const SCHEMA_SETTING_NAME = 'MAJ_ADMTASKS_SCHEMA_VERSION'; |
|
54 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
51 | + //How to update the database schema for this module |
|
52 | + private const SCHEMA_TARGET_VERSION = 2; |
|
53 | + private const SCHEMA_SETTING_NAME = 'MAJ_ADMTASKS_SCHEMA_VERSION'; |
|
54 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
55 | 55 | |
56 | - /** |
|
57 | - * {@inheritDoc} |
|
58 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
59 | - */ |
|
60 | - public function title(): string |
|
61 | - { |
|
62 | - return I18N::translate('Administration Tasks'); |
|
63 | - } |
|
56 | + /** |
|
57 | + * {@inheritDoc} |
|
58 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
59 | + */ |
|
60 | + public function title(): string |
|
61 | + { |
|
62 | + return I18N::translate('Administration Tasks'); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * {@inheritDoc} |
|
67 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
68 | - */ |
|
69 | - public function description(): string |
|
70 | - { |
|
71 | - return I18N::translate('Manage and run nearly-scheduled administration tasks.'); |
|
72 | - } |
|
65 | + /** |
|
66 | + * {@inheritDoc} |
|
67 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
68 | + */ |
|
69 | + public function description(): string |
|
70 | + { |
|
71 | + return I18N::translate('Manage and run nearly-scheduled administration tasks.'); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * {@inheritDoc} |
|
76 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
77 | - */ |
|
78 | - public function boot(): void |
|
79 | - { |
|
80 | - parent::boot(); |
|
81 | - app(MigrationService::class)->updateSchema( |
|
82 | - self::SCHEMA_MIGRATION_PREFIX, |
|
83 | - self::SCHEMA_SETTING_NAME, |
|
84 | - self::SCHEMA_TARGET_VERSION |
|
85 | - ); |
|
86 | - } |
|
74 | + /** |
|
75 | + * {@inheritDoc} |
|
76 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
77 | + */ |
|
78 | + public function boot(): void |
|
79 | + { |
|
80 | + parent::boot(); |
|
81 | + app(MigrationService::class)->updateSchema( |
|
82 | + self::SCHEMA_MIGRATION_PREFIX, |
|
83 | + self::SCHEMA_SETTING_NAME, |
|
84 | + self::SCHEMA_TARGET_VERSION |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * {@inheritDoc} |
|
90 | - * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::loadRoutes() |
|
91 | - */ |
|
92 | - public function loadRoutes(Map $router): void |
|
93 | - { |
|
94 | - $router->attach('', '', static function (Map $router) { |
|
88 | + /** |
|
89 | + * {@inheritDoc} |
|
90 | + * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::loadRoutes() |
|
91 | + */ |
|
92 | + public function loadRoutes(Map $router): void |
|
93 | + { |
|
94 | + $router->attach('', '', static function (Map $router) { |
|
95 | 95 | |
96 | - $router->attach('', '/module-maj/admintasks', static function (Map $router) { |
|
96 | + $router->attach('', '/module-maj/admintasks', static function (Map $router) { |
|
97 | 97 | |
98 | - $router->attach('', '/admin', static function (Map $router) { |
|
98 | + $router->attach('', '/admin', static function (Map $router) { |
|
99 | 99 | |
100 | - $router->extras([ |
|
101 | - 'middleware' => [ |
|
102 | - AuthAdministrator::class, |
|
103 | - ], |
|
104 | - ]); |
|
105 | - $router->get(AdminConfigPage::class, '/config', AdminConfigPage::class); |
|
100 | + $router->extras([ |
|
101 | + 'middleware' => [ |
|
102 | + AuthAdministrator::class, |
|
103 | + ], |
|
104 | + ]); |
|
105 | + $router->get(AdminConfigPage::class, '/config', AdminConfigPage::class); |
|
106 | 106 | |
107 | - $router->attach('', '/tasks', static function (Map $router) { |
|
107 | + $router->attach('', '/tasks', static function (Map $router) { |
|
108 | 108 | |
109 | - $router->get(TasksList::class, '', TasksList::class); |
|
110 | - $router->get(TaskEditPage::class, '/{task}', TaskEditPage::class); |
|
111 | - $router->post(TaskEditAction::class, '/{task}', TaskEditAction::class); |
|
112 | - $router->get(TaskStatusAction::class, '/{task}/status/{enable}', TaskStatusAction::class); |
|
113 | - }); |
|
114 | - }); |
|
109 | + $router->get(TasksList::class, '', TasksList::class); |
|
110 | + $router->get(TaskEditPage::class, '/{task}', TaskEditPage::class); |
|
111 | + $router->post(TaskEditAction::class, '/{task}', TaskEditAction::class); |
|
112 | + $router->get(TaskStatusAction::class, '/{task}/status/{enable}', TaskStatusAction::class); |
|
113 | + }); |
|
114 | + }); |
|
115 | 115 | |
116 | - $router->get(TaskTrigger::class, '/trigger{/task}', TaskTrigger::class) |
|
117 | - ->allows(RequestMethodInterface::METHOD_POST); |
|
116 | + $router->get(TaskTrigger::class, '/trigger{/task}', TaskTrigger::class) |
|
117 | + ->allows(RequestMethodInterface::METHOD_POST); |
|
118 | 118 | |
119 | - $router->post(TokenGenerate::class, '/token', TokenGenerate::class) |
|
120 | - ->extras(['middleware' => [AuthAdministrator::class]]); |
|
121 | - }); |
|
122 | - }); |
|
123 | - } |
|
119 | + $router->post(TokenGenerate::class, '/token', TokenGenerate::class) |
|
120 | + ->extras(['middleware' => [AuthAdministrator::class]]); |
|
121 | + }); |
|
122 | + }); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * {@inheritDoc} |
|
127 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleLatestVersion() |
|
128 | - */ |
|
129 | - public function customModuleVersion(): string |
|
130 | - { |
|
131 | - return '2.0.5-v.1'; |
|
132 | - } |
|
125 | + /** |
|
126 | + * {@inheritDoc} |
|
127 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleLatestVersion() |
|
128 | + */ |
|
129 | + public function customModuleVersion(): string |
|
130 | + { |
|
131 | + return '2.0.5-v.1'; |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * {@inheritDoc} |
|
136 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
137 | - */ |
|
138 | - public function getConfigLink(): string |
|
139 | - { |
|
140 | - return route(AdminConfigPage::class); |
|
141 | - } |
|
134 | + /** |
|
135 | + * {@inheritDoc} |
|
136 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
137 | + */ |
|
138 | + public function getConfigLink(): string |
|
139 | + { |
|
140 | + return route(AdminConfigPage::class); |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * {@inheritDoc} |
|
145 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::bodyContent() |
|
146 | - */ |
|
147 | - public function bodyContent(): string |
|
148 | - { |
|
149 | - $parameters['url'] = route(TaskTrigger::class); |
|
143 | + /** |
|
144 | + * {@inheritDoc} |
|
145 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::bodyContent() |
|
146 | + */ |
|
147 | + public function bodyContent(): string |
|
148 | + { |
|
149 | + $parameters['url'] = route(TaskTrigger::class); |
|
150 | 150 | |
151 | - return view($this->name() . '::snippet', $parameters); |
|
152 | - } |
|
151 | + return view($this->name() . '::snippet', $parameters); |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * {@inheritDoc} |
|
156 | - * @see \MyArtJaub\Webtrees\Module\AdminTasks\Contracts\ModuleTasksProviderInterface::listTasks() |
|
157 | - */ |
|
158 | - public function listTasks(): array |
|
159 | - { |
|
160 | - return [ |
|
161 | - 'maj-healthcheck' => HealthCheckEmailTask::class |
|
162 | - ]; |
|
163 | - } |
|
154 | + /** |
|
155 | + * {@inheritDoc} |
|
156 | + * @see \MyArtJaub\Webtrees\Module\AdminTasks\Contracts\ModuleTasksProviderInterface::listTasks() |
|
157 | + */ |
|
158 | + public function listTasks(): array |
|
159 | + { |
|
160 | + return [ |
|
161 | + 'maj-healthcheck' => HealthCheckEmailTask::class |
|
162 | + ]; |
|
163 | + } |
|
164 | 164 | } |