@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | $query = DB::table('maj_admintasks') |
196 | 196 | ->select() |
197 | 197 | ->where('majat_status', '=', 'enabled') |
198 | - ->where(function (Builder $query) { |
|
198 | + ->where(function(Builder $query) { |
|
199 | 199 | |
200 | 200 | $query->where('majat_running', '=', 0) |
201 | 201 | ->orWhere('majat_last_run', '<=', Carbon::now()->subSeconds(self::TASK_TIME_OUT)); |
202 | 202 | }); |
203 | 203 | |
204 | 204 | if (!$force) { |
205 | - $query->where(function (Builder $query) { |
|
205 | + $query->where(function(Builder $query) { |
|
206 | 206 | |
207 | 207 | $query->where('majat_running', '=', 0) |
208 | 208 | ->orWhereRaw('DATE_ADD(majat_last_run, INTERVAL majat_frequency MINUTE) <= NOW()'); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | if ( |
239 | 239 | !$task_schedule->isRunning() && |
240 | 240 | ($force || $task_schedule->lastRunTime()->add($task_schedule->frequency())->lessThan(Carbon::now())) && |
241 | - $task_schedule->setLastResult(false) && // @phpstan-ignore-line Used as setter, not as a condition |
|
241 | + $task_schedule->setLastResult(false) && // @phpstan-ignore-line Used as setter, not as a condition |
|
242 | 242 | $task = $this->findTask($task_schedule->taskId()) |
243 | 243 | ) { |
244 | 244 | $task_schedule->startRunning(); |
@@ -267,17 +267,17 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public static function rowMapper(): Closure |
269 | 269 | { |
270 | - return static function (stdClass $row): TaskSchedule { |
|
270 | + return static function(stdClass $row): TaskSchedule { |
|
271 | 271 | |
272 | 272 | return new TaskSchedule( |
273 | - (int) $row->majat_id, |
|
273 | + (int)$row->majat_id, |
|
274 | 274 | $row->majat_task_id, |
275 | 275 | $row->majat_status === 'enabled', |
276 | 276 | Carbon::parse($row->majat_last_run), |
277 | - (bool) $row->majat_last_result, |
|
277 | + (bool)$row->majat_last_result, |
|
278 | 278 | CarbonInterval::minutes($row->majat_frequency), |
279 | - (int) $row->majat_nb_occur, |
|
280 | - (bool) $row->majat_running |
|
279 | + (int)$row->majat_nb_occur, |
|
280 | + (bool)$row->majat_running |
|
281 | 281 | ); |
282 | 282 | }; |
283 | 283 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function changesByRecordType(Tree $tree, int $nb_days): Collection |
80 | 80 | { |
81 | 81 | return DB::table('change') |
82 | - ->joinSub($this->allGedcomRecords($tree), 'gedrecords', function (JoinClause $join) use ($tree) { |
|
82 | + ->joinSub($this->allGedcomRecords($tree), 'gedrecords', function(JoinClause $join) use ($tree) { |
|
83 | 83 | |
84 | 84 | $join->on('change.xref', '=', 'gedrecords.ged_id') |
85 | 85 | ->where('change.gedcom_id', '=', $tree->id()); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | new Expression('MAX(log_time) AS lastoccurred') |
116 | 116 | ) |
117 | 117 | ->where('log_type', '=', 'error') |
118 | - ->where(function (Builder $query) use ($tree) { |
|
118 | + ->where(function(Builder $query) use ($tree) { |
|
119 | 119 | $query->where('gedcom_id', '=', $tree->id()) |
120 | 120 | ->orWhereNull('gedcom_id'); |
121 | 121 | }) |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | $task_schedules = $this->taskschedules_service->all(true, true) |
77 | - ->map(function (TaskSchedule $value) { |
|
77 | + ->map(function(TaskSchedule $value) { |
|
78 | 78 | |
79 | 79 | $row = $value->toArray(); |
80 | 80 | $task = $this->taskschedules_service->findTask($row['task_id']); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $sort_columns = ['task_name', 'enabled', 'last_run']; |
87 | 87 | $module_name = $this->module->name(); |
88 | 88 | |
89 | - $callback = function (array $row) use ($module_name): array { |
|
89 | + $callback = function(array $row) use ($module_name): array { |
|
90 | 90 | |
91 | 91 | $row['frequency']->setLocale(I18N::locale()->code()); |
92 | 92 | |
@@ -109,21 +109,20 @@ discard block |
||
109 | 109 | ]; |
110 | 110 | |
111 | 111 | $datum = [ |
112 | - view($module_name . '::admin/tasks-table-options', $task_options_params), |
|
113 | - view($module_name . '::components/yes-no-icons', ['yes' => $row['enabled']]), |
|
114 | - '<span dir="auto">' . e($row['task_name']) . '</span>', |
|
112 | + view($module_name.'::admin/tasks-table-options', $task_options_params), |
|
113 | + view($module_name.'::components/yes-no-icons', ['yes' => $row['enabled']]), |
|
114 | + '<span dir="auto">'.e($row['task_name']).'</span>', |
|
115 | 115 | $row['last_run']->unix() === 0 ? |
116 | - view('components/datetime', ['timestamp' => $row['last_run']]) : |
|
117 | - view('components/datetime-diff', ['timestamp' => $row['last_run']]), |
|
118 | - view($module_name . '::components/yes-no-icons', ['yes' => $row['last_result']]), |
|
119 | - '<span dir="auto">' . e($row['frequency']->cascade()->forHumans()) . '</span>', |
|
116 | + view('components/datetime', ['timestamp' => $row['last_run']]) : view('components/datetime-diff', ['timestamp' => $row['last_run']]), |
|
117 | + view($module_name.'::components/yes-no-icons', ['yes' => $row['last_result']]), |
|
118 | + '<span dir="auto">'.e($row['frequency']->cascade()->forHumans()).'</span>', |
|
120 | 119 | $row['nb_occurrences'] > 0 ? I18N::number($row['nb_occurrences']) : I18N::translate('Unlimited'), |
121 | - view($module_name . '::components/yes-no-icons', [ |
|
120 | + view($module_name.'::components/yes-no-icons', [ |
|
122 | 121 | 'yes' => $row['is_running'], |
123 | 122 | 'text_yes' => I18N::translate('Running'), |
124 | 123 | 'text_no' => I18N::translate('Not running') |
125 | 124 | ]), |
126 | - view($module_name . '::admin/tasks-table-run', $task_run_params) |
|
125 | + view($module_name.'::admin/tasks-table-run', $task_run_params) |
|
127 | 126 | ]; |
128 | 127 | |
129 | 128 | return $datum; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function handle(ServerRequestInterface $request): ResponseInterface |
60 | 60 | { |
61 | - $task_sched_id = (int) $request->getAttribute('task'); |
|
61 | + $task_sched_id = (int)$request->getAttribute('task'); |
|
62 | 62 | $task_schedule = $this->taskschedules_service->find($task_sched_id); |
63 | 63 | |
64 | 64 | $admin_config_route = route(AdminConfigPage::class); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | return redirect($admin_config_route); |
72 | 72 | } |
73 | 73 | |
74 | - ((bool) $request->getAttribute('enable', false)) ? $task_schedule->enable() : $task_schedule->disable(); |
|
74 | + ((bool)$request->getAttribute('enable', false)) ? $task_schedule->enable() : $task_schedule->disable(); |
|
75 | 75 | |
76 | 76 | if ($this->taskschedules_service->update($task_schedule) > 0) { |
77 | 77 | FlashMessages::addMessage( |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | 'success' |
80 | 80 | ); |
81 | 81 | //phpcs:ignore Generic.Files.LineLength.TooLong |
82 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.'); |
|
82 | + Log::addConfigurationLog('Module '.$this->module->title().' : Task Schedule “'.$task_schedule->id().'” has been updated.'); |
|
83 | 83 | } else { |
84 | 84 | FlashMessages::addMessage( |
85 | 85 | I18N::translate('An error occured while updating the scheduled task'), |
86 | 86 | 'danger' |
87 | 87 | ); |
88 | 88 | //phpcs:ignore Generic.Files.LineLength.TooLong |
89 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.'); |
|
89 | + Log::addConfigurationLog('Module '.$this->module->title().' : Task Schedule “'.$task_schedule->id().'” could not be updated. See error log.'); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | return redirect($admin_config_route); |
@@ -56,7 +56,7 @@ |
||
56 | 56 | |
57 | 57 | $token = Functions::generateRandomToken(); |
58 | 58 | $this->module->setPreference('MAJ_AT_FORCE_EXEC_TOKEN', $token); |
59 | - Log::addConfigurationLog($this->module->title() . ' : New token generated.'); |
|
59 | + Log::addConfigurationLog($this->module->title().' : New token generated.'); |
|
60 | 60 | |
61 | 61 | return response(['token' => $token]); |
62 | 62 | } |
@@ -73,7 +73,7 @@ |
||
73 | 73 | $this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token); |
74 | 74 | } |
75 | 75 | |
76 | - return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
76 | + return $this->viewResponse($this->module->name().'::admin/config', [ |
|
77 | 77 | 'title' => $this->module->title(), |
78 | 78 | 'trigger_token' => $token, |
79 | 79 | 'trigger_route' => route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']), |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function handle(ServerRequestInterface $request): ResponseInterface |
64 | 64 | { |
65 | - $task_sched_id = (int) $request->getAttribute('task'); |
|
65 | + $task_sched_id = (int)$request->getAttribute('task'); |
|
66 | 66 | $task_schedule = $this->taskschedules_service->find($task_sched_id); |
67 | 67 | |
68 | 68 | $admin_config_route = route(AdminConfigPage::class); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | 'success' |
85 | 85 | ); |
86 | 86 | //phpcs:ignore Generic.Files.LineLength.TooLong |
87 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.'); |
|
87 | + Log::addConfigurationLog('Module '.$this->module->title().' : Task Schedule “'.$task_schedule->id().'” has been updated.'); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | return redirect($admin_config_route); |
@@ -99,17 +99,17 @@ discard block |
||
99 | 99 | */ |
100 | 100 | private function updateGeneralSettings(TaskSchedule $task_schedule, ServerRequestInterface $request): bool |
101 | 101 | { |
102 | - $params = (array) $request->getParsedBody(); |
|
102 | + $params = (array)$request->getParsedBody(); |
|
103 | 103 | |
104 | - $frequency = (int) $params['frequency']; |
|
104 | + $frequency = (int)$params['frequency']; |
|
105 | 105 | if ($frequency > 0) { |
106 | 106 | $task_schedule->setFrequency(CarbonInterval::minutes($frequency)); |
107 | 107 | } else { |
108 | 108 | FlashMessages::addMessage(I18N::translate('The frequency is not in a valid format'), 'danger'); |
109 | 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 | 114 | if ($is_limited) { |
115 | 115 | if ($nb_occur > 0) { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | FlashMessages::addMessage(I18N::translate('An error occured while updating the scheduled task'), 'danger'); |
141 | 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.'); |
|
142 | + Log::addConfigurationLog('Module '.$this->module->title().' : Task Schedule “'.$task_schedule->id().'” could not be updated. See error log.'); |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | 'danger' |
168 | 168 | ); |
169 | 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.'); |
|
170 | + Log::addConfigurationLog('Module '.$this->module->title().' : AdminTask “'.$task->name().'” specific settings could not be updated. See error log.'); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | return true; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $interval_lastrun = $task_schedule->lastRunTime()->diffAsCarbonInterval(Carbon::now()); |
137 | 137 | //@phpcs:ignore Generic.Files.LineLength.TooLong |
138 | 138 | $interval = $interval_lastrun->greaterThan($task_schedule->frequency()) ? $interval_lastrun : $task_schedule->frequency(); |
139 | - $nb_days = (int) $interval->ceilDay()->totalDays; |
|
139 | + $nb_days = (int)$interval->ceilDay()->totalDays; |
|
140 | 140 | |
141 | 141 | $view_params_site = [ |
142 | 142 | 'nb_days' => $nb_days, |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | continue; |
156 | 156 | } |
157 | 157 | |
158 | - $webmaster = $this->user_service->find((int) $tree->getPreference('WEBMASTER_USER_ID')); |
|
158 | + $webmaster = $this->user_service->find((int)$tree->getPreference('WEBMASTER_USER_ID')); |
|
159 | 159 | if ($webmaster === null) { |
160 | 160 | continue; |
161 | 161 | } |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | new TreeUser($tree), |
177 | 177 | $webmaster, |
178 | 178 | new NoReplyUser(), |
179 | - I18N::translate('Health Check Report') . ' - ' . I18N::translate('Tree %s', $tree->name()), |
|
180 | - view($this->module->name() . '::tasks/healthcheck/email-healthcheck-text', $view_params), |
|
181 | - view($this->module->name() . '::tasks/healthcheck/email-healthcheck-html', $view_params) |
|
179 | + I18N::translate('Health Check Report').' - '.I18N::translate('Tree %s', $tree->name()), |
|
180 | + view($this->module->name().'::tasks/healthcheck/email-healthcheck-text', $view_params), |
|
181 | + view($this->module->name().'::tasks/healthcheck/email-healthcheck-html', $view_params) |
|
182 | 182 | ); |
183 | 183 | } |
184 | 184 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function configView(ServerRequestInterface $request): string |
193 | 193 | { |
194 | - return view($this->module->name() . '::tasks/healthcheck/config', [ |
|
194 | + return view($this->module->name().'::tasks/healthcheck/config', [ |
|
195 | 195 | 'all_trees' => $this->tree_service->all() |
196 | 196 | ]); |
197 | 197 | } |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool |
204 | 204 | { |
205 | 205 | try { |
206 | - $params = (array) $request->getParsedBody(); |
|
206 | + $params = (array)$request->getParsedBody(); |
|
207 | 207 | |
208 | 208 | foreach ($this->tree_service->all() as $tree) { |
209 | 209 | if (Auth::isManager($tree)) { |
210 | - $tree_enabled = (bool) ($params['HEALTHCHECK_ENABLED_' . $tree->id()] ?? false); |
|
210 | + $tree_enabled = (bool)($params['HEALTHCHECK_ENABLED_'.$tree->id()] ?? false); |
|
211 | 211 | $tree->setPreference(self::TREE_PREFERENCE_NAME, $tree_enabled ? '1' : '0'); |
212 | 212 | } |
213 | 213 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | //How to update the database schema for this module |
52 | 52 | private const SCHEMA_TARGET_VERSION = 2; |
53 | 53 | private const SCHEMA_SETTING_NAME = 'MAJ_ADMTASKS_SCHEMA_VERSION'; |
54 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
54 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema'; |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * {@inheritDoc} |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function loadRoutes(Map $router): void |
93 | 93 | { |
94 | - $router->attach('', '', static function (Map $router) { |
|
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 | 100 | $router->extras([ |
101 | 101 | 'middleware' => [ |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | ]); |
105 | 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 | 109 | $router->get(TasksList::class, '', TasksList::class); |
110 | 110 | $router->get(TaskEditPage::class, '/{task}', TaskEditPage::class); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | { |
149 | 149 | $parameters['url'] = route(TaskTrigger::class); |
150 | 150 | |
151 | - return view($this->name() . '::snippet', $parameters); |
|
151 | + return view($this->name().'::snippet', $parameters); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |