Passed
Branch feature/2.0 (2da243)
by Jonathan
05:05
created
src/Webtrees/Module/AdminTasks/Http/RequestHandlers/AdminConfigPage.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -30,55 +30,55 @@
 block discarded – undo
30 30
  */
31 31
 class AdminConfigPage implements RequestHandlerInterface
32 32
 {
33
-    use ViewResponseTrait;
33
+	use ViewResponseTrait;
34 34
 
35
-    /**
36
-     * @var AdminTasksModule $module
37
-     */
38
-    private $module;
35
+	/**
36
+	 * @var AdminTasksModule $module
37
+	 */
38
+	private $module;
39 39
     
40
-    /**
41
-     *
42
-     * @var UserService $user_service
43
-     */
44
-    private $user_service;
40
+	/**
41
+	 *
42
+	 * @var UserService $user_service
43
+	 */
44
+	private $user_service;
45 45
     
46
-    /**
47
-     * Constructor for Admin Config request handler
48
-     *
49
-     * @param ModuleService $module_service
50
-     * @param UserService $user_service
51
-     */
52
-    public function __construct(ModuleService $module_service, UserService $user_service)
53
-    {
54
-        $this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
55
-        $this->user_service = $user_service;
56
-    }
46
+	/**
47
+	 * Constructor for Admin Config request handler
48
+	 *
49
+	 * @param ModuleService $module_service
50
+	 * @param UserService $user_service
51
+	 */
52
+	public function __construct(ModuleService $module_service, UserService $user_service)
53
+	{
54
+		$this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
55
+		$this->user_service = $user_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
-        $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN');
71
-        if ($token === '') {
72
-            $token = Functions::generateRandomToken();
73
-            $this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token);
74
-        }
70
+		$token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN');
71
+		if ($token === '') {
72
+			$token = Functions::generateRandomToken();
73
+			$this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token);
74
+		}
75 75
         
76
-        return $this->viewResponse($this->module->name() . '::admin/config', [
77
-            'title'             =>  $this->module->title(),
78
-            'trigger_token'     =>  $token,
79
-            'trigger_route'     =>  route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']),
80
-            'new_token_route'   =>  route(TokenGenerate::class),
81
-            'tasks_data_route'  =>  route(TasksList::class)
82
-        ]);
83
-    }
76
+		return $this->viewResponse($this->module->name() . '::admin/config', [
77
+			'title'             =>  $this->module->title(),
78
+			'trigger_token'     =>  $token,
79
+			'trigger_route'     =>  route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']),
80
+			'new_token_route'   =>  route(TokenGenerate::class),
81
+			'tasks_data_route'  =>  route(TasksList::class)
82
+		]);
83
+	}
84 84
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Http/RequestHandlers/TaskTrigger.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -29,48 +29,48 @@
 block discarded – undo
29 29
  */
30 30
 class TaskTrigger implements RequestHandlerInterface
31 31
 {
32
-    /**
33
-     * @var AdminTasksModule $module
34
-     */
35
-    private $module;
32
+	/**
33
+	 * @var AdminTasksModule $module
34
+	 */
35
+	private $module;
36 36
     
37
-    /**
38
-     * @var TaskScheduleService $taskschedules_service
39
-     */
40
-    private $taskschedules_service;
37
+	/**
38
+	 * @var TaskScheduleService $taskschedules_service
39
+	 */
40
+	private $taskschedules_service;
41 41
     
42
-    /**
43
-     * Constructor for TaskTrigger request handler
44
-     * @param ModuleService $module_service
45
-     * @param TaskScheduleService $taskschedules_service
46
-     */
47
-    public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service)
48
-    {
49
-        $this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
50
-        $this->taskschedules_service = $taskschedules_service;
51
-    }
42
+	/**
43
+	 * Constructor for TaskTrigger request handler
44
+	 * @param ModuleService $module_service
45
+	 * @param TaskScheduleService $taskschedules_service
46
+	 */
47
+	public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service)
48
+	{
49
+		$this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
50
+		$this->taskschedules_service = $taskschedules_service;
51
+	}
52 52
 
53
-    /**
54
-     * {@inheritDoc}
55
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
56
-     */
57
-    public function handle(ServerRequestInterface $request): ResponseInterface
58
-    {
59
-        if ($this->module === null) {
60
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
61
-        }
53
+	/**
54
+	 * {@inheritDoc}
55
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
56
+	 */
57
+	public function handle(ServerRequestInterface $request): ResponseInterface
58
+	{
59
+		if ($this->module === null) {
60
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
61
+		}
62 62
         
63
-        $task_id = $request->getAttribute('task');
64
-        $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN');
65
-        $force_token = $request->getQueryParams()['force'] ?? '';
66
-        $force = $token == $force_token;
63
+		$task_id = $request->getAttribute('task');
64
+		$token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN');
65
+		$force_token = $request->getQueryParams()['force'] ?? '';
66
+		$force = $token == $force_token;
67 67
         
68
-        $task_schedules = $this->taskschedules_service->findTasksToRun($force, $task_id);
68
+		$task_schedules = $this->taskschedules_service->findTasksToRun($force, $task_id);
69 69
         
70
-        foreach ($task_schedules as $task_schedule) {
71
-            $this->taskschedules_service->run($task_schedule, $force);
72
-        }
70
+		foreach ($task_schedules as $task_schedule) {
71
+			$this->taskschedules_service->run($task_schedule, $force);
72
+		}
73 73
         
74
-        return response();
75
-    }
74
+		return response();
75
+	}
76 76
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Tasks/HealthCheckEmailTask.php 1 patch
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -39,188 +39,188 @@
 block discarded – undo
39 39
  */
40 40
 class HealthCheckEmailTask implements TaskInterface, ConfigurableTaskInterface
41 41
 {
42
-    /**
43
-     * Name of the Tree preference to check if the task is enabled for that tree
44
-     * @var string
45
-     */
46
-    public const TREE_PREFERENCE_NAME = 'MAJ_AT_HEALTHCHECK_ENABLED';
42
+	/**
43
+	 * Name of the Tree preference to check if the task is enabled for that tree
44
+	 * @var string
45
+	 */
46
+	public const TREE_PREFERENCE_NAME = 'MAJ_AT_HEALTHCHECK_ENABLED';
47 47
     
48
-    /**
49
-     * @var AdminTasksModule $module
50
-     */
51
-    private $module;
48
+	/**
49
+	 * @var AdminTasksModule $module
50
+	 */
51
+	private $module;
52 52
     
53
-    /**
54
-     * @var HealthCheckService $healthcheck_service;
55
-     */
56
-    private $healthcheck_service;
53
+	/**
54
+	 * @var HealthCheckService $healthcheck_service;
55
+	 */
56
+	private $healthcheck_service;
57 57
     
58
-    /**
59
-     * @var EmailService $email_service;
60
-     */
61
-    private $email_service;
58
+	/**
59
+	 * @var EmailService $email_service;
60
+	 */
61
+	private $email_service;
62 62
     
63
-    /**
64
-     * @var UserService $user_service
65
-     */
66
-    private $user_service;
63
+	/**
64
+	 * @var UserService $user_service
65
+	 */
66
+	private $user_service;
67 67
     
68
-    /**
69
-     * @var TreeService $tree_service
70
-     */
71
-    private $tree_service;
68
+	/**
69
+	 * @var TreeService $tree_service
70
+	 */
71
+	private $tree_service;
72 72
     
73
-    /**
74
-     * @var UpgradeService $upgrade_service
75
-     */
76
-    private $upgrade_service;
73
+	/**
74
+	 * @var UpgradeService $upgrade_service
75
+	 */
76
+	private $upgrade_service;
77 77
     
78
-    /**
79
-     * Constructor for HealthCheckTask
80
-     *
81
-     * @param ModuleService $module_service
82
-     * @param HealthCheckService $healthcheck_service
83
-     * @param EmailService $email_service
84
-     * @param UserService $user_service
85
-     * @param TreeService $tree_service
86
-     * @param UpgradeService $upgrade_service
87
-     */
88
-    public function __construct(
89
-        ModuleService $module_service,
90
-        HealthCheckService $healthcheck_service,
91
-        EmailService $email_service,
92
-        UserService $user_service,
93
-        TreeService $tree_service,
94
-        UpgradeService $upgrade_service
95
-    ) {
96
-        $this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
97
-        $this->healthcheck_service = $healthcheck_service;
98
-        $this->email_service = $email_service;
99
-        $this->user_service = $user_service;
100
-        $this->tree_service = $tree_service;
101
-        $this->upgrade_service = $upgrade_service;
102
-    }
78
+	/**
79
+	 * Constructor for HealthCheckTask
80
+	 *
81
+	 * @param ModuleService $module_service
82
+	 * @param HealthCheckService $healthcheck_service
83
+	 * @param EmailService $email_service
84
+	 * @param UserService $user_service
85
+	 * @param TreeService $tree_service
86
+	 * @param UpgradeService $upgrade_service
87
+	 */
88
+	public function __construct(
89
+		ModuleService $module_service,
90
+		HealthCheckService $healthcheck_service,
91
+		EmailService $email_service,
92
+		UserService $user_service,
93
+		TreeService $tree_service,
94
+		UpgradeService $upgrade_service
95
+	) {
96
+		$this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
97
+		$this->healthcheck_service = $healthcheck_service;
98
+		$this->email_service = $email_service;
99
+		$this->user_service = $user_service;
100
+		$this->tree_service = $tree_service;
101
+		$this->upgrade_service = $upgrade_service;
102
+	}
103 103
     
104 104
     
105
-    /**
106
-     * {@inheritDoc}
107
-     * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskInterface::name()
108
-     */
109
-    public function name(): string
110
-    {
111
-        return I18N::translate('Healthcheck Email');
112
-    }
105
+	/**
106
+	 * {@inheritDoc}
107
+	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskInterface::name()
108
+	 */
109
+	public function name(): string
110
+	{
111
+		return I18N::translate('Healthcheck Email');
112
+	}
113 113
     
114
-    /**
115
-     * {@inheritDoc}
116
-     * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskInterface::defaultFrequency()
117
-     */
118
-    public function defaultFrequency(): int
119
-    {
120
-        return 10080; // = 1 week = 7 * 24 * 60 min
121
-    }
114
+	/**
115
+	 * {@inheritDoc}
116
+	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskInterface::defaultFrequency()
117
+	 */
118
+	public function defaultFrequency(): int
119
+	{
120
+		return 10080; // = 1 week = 7 * 24 * 60 min
121
+	}
122 122
     
123
-    /**
124
-     * {@inheritDoc}
125
-     * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskInterface::run()
126
-     */
127
-    public function run(TaskSchedule $task_schedule): bool
128
-    {
129
-        if ($this->module === null) {
130
-            return false;
131
-        }
123
+	/**
124
+	 * {@inheritDoc}
125
+	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskInterface::run()
126
+	 */
127
+	public function run(TaskSchedule $task_schedule): bool
128
+	{
129
+		if ($this->module === null) {
130
+			return false;
131
+		}
132 132
         
133
-        $res = true;
133
+		$res = true;
134 134
         
135
-        // Compute the number of days to compute
136
-        $interval_lastrun = $task_schedule->lastRunTime()->diffAsCarbonInterval(Carbon::now());
137
-        //@phpcs:ignore Generic.Files.LineLength.TooLong
138
-        $interval = $interval_lastrun->greaterThan($task_schedule->frequency()) ? $interval_lastrun : $task_schedule->frequency();
139
-        $nb_days = (int) $interval->ceilDay()->totalDays;
135
+		// Compute the number of days to compute
136
+		$interval_lastrun = $task_schedule->lastRunTime()->diffAsCarbonInterval(Carbon::now());
137
+		//@phpcs:ignore Generic.Files.LineLength.TooLong
138
+		$interval = $interval_lastrun->greaterThan($task_schedule->frequency()) ? $interval_lastrun : $task_schedule->frequency();
139
+		$nb_days = (int) $interval->ceilDay()->totalDays;
140 140
         
141
-        $view_params_site = [
142
-            'nb_days'               =>  $nb_days,
143
-            'upgrade_available'     =>  $this->upgrade_service->isUpgradeAvailable(),
144
-            'latest_version'        =>  $this->upgrade_service->latestVersion(),
145
-            'download_url'          =>  $this->upgrade_service->downloadUrl(),
146
-            'all_users'             =>  $this->user_service->all(),
147
-            'unapproved'            =>  $this->user_service->unapproved(),
148
-            'unverified'            =>  $this->user_service->unverified(),
149
-        ];
141
+		$view_params_site = [
142
+			'nb_days'               =>  $nb_days,
143
+			'upgrade_available'     =>  $this->upgrade_service->isUpgradeAvailable(),
144
+			'latest_version'        =>  $this->upgrade_service->latestVersion(),
145
+			'download_url'          =>  $this->upgrade_service->downloadUrl(),
146
+			'all_users'             =>  $this->user_service->all(),
147
+			'unapproved'            =>  $this->user_service->unapproved(),
148
+			'unverified'            =>  $this->user_service->unverified(),
149
+		];
150 150
         
151
-        foreach ($this->tree_service->all() as $tree) {
152
-        /** @var Tree $tree */
151
+		foreach ($this->tree_service->all() as $tree) {
152
+		/** @var Tree $tree */
153 153
             
154
-            if ($tree->getPreference(self::TREE_PREFERENCE_NAME) !== '1') {
155
-                continue;
156
-            }
154
+			if ($tree->getPreference(self::TREE_PREFERENCE_NAME) !== '1') {
155
+				continue;
156
+			}
157 157
             
158
-            $webmaster = $this->user_service->find((int) $tree->getPreference('WEBMASTER_USER_ID'));
159
-            if ($webmaster === null) {
160
-                continue;
161
-            }
162
-            I18N::init($webmaster->getPreference('language'));
158
+			$webmaster = $this->user_service->find((int) $tree->getPreference('WEBMASTER_USER_ID'));
159
+			if ($webmaster === null) {
160
+				continue;
161
+			}
162
+			I18N::init($webmaster->getPreference('language'));
163 163
             
164
-            $error_logs = $this->healthcheck_service->errorLogs($tree, $nb_days);
165
-            $nb_errors = $error_logs->sum('nblogs');
164
+			$error_logs = $this->healthcheck_service->errorLogs($tree, $nb_days);
165
+			$nb_errors = $error_logs->sum('nblogs');
166 166
             
167
-            $view_params = array_merge($view_params_site, [
168
-                'tree'              =>  $tree,
169
-                'total_by_type'     =>  $this->healthcheck_service->countByRecordType($tree),
170
-                'change_by_type'    =>  $this->healthcheck_service->changesByRecordType($tree, $nb_days),
171
-                'error_logs'        =>  $error_logs,
172
-                'nb_errors'         =>  $nb_errors
173
-            ]);
167
+			$view_params = array_merge($view_params_site, [
168
+				'tree'              =>  $tree,
169
+				'total_by_type'     =>  $this->healthcheck_service->countByRecordType($tree),
170
+				'change_by_type'    =>  $this->healthcheck_service->changesByRecordType($tree, $nb_days),
171
+				'error_logs'        =>  $error_logs,
172
+				'nb_errors'         =>  $nb_errors
173
+			]);
174 174
             
175
-            $res = $res && $this->email_service->send(
176
-                new TreeUser($tree),
177
-                $webmaster,
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)
182
-            );
183
-        }
175
+			$res = $res && $this->email_service->send(
176
+				new TreeUser($tree),
177
+				$webmaster,
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)
182
+			);
183
+		}
184 184
         
185
-        return $res;
186
-    }
185
+		return $res;
186
+	}
187 187
 
188
-    /**
189
-     * {@inheritDoc}
190
-     * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface::configView()
191
-     */
192
-    public function configView(ServerRequestInterface $request): string
193
-    {
194
-        return view($this->module->name() . '::tasks/healthcheck/config', [
195
-            'all_trees'     =>  $this->tree_service->all()
196
-        ]);
197
-    }
188
+	/**
189
+	 * {@inheritDoc}
190
+	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface::configView()
191
+	 */
192
+	public function configView(ServerRequestInterface $request): string
193
+	{
194
+		return view($this->module->name() . '::tasks/healthcheck/config', [
195
+			'all_trees'     =>  $this->tree_service->all()
196
+		]);
197
+	}
198 198
     
199
-    /**
200
-     * {@inheritDoc}
201
-     * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface::updateConfig()
202
-     */
203
-    public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool
204
-    {
205
-        try {
206
-            $params = (array) $request->getParsedBody();
199
+	/**
200
+	 * {@inheritDoc}
201
+	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface::updateConfig()
202
+	 */
203
+	public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool
204
+	{
205
+		try {
206
+			$params = (array) $request->getParsedBody();
207 207
             
208
-            foreach ($this->tree_service->all() as $tree) {
209
-                if (Auth::isManager($tree)) {
210
-                    $tree_enabled = (bool) ($params['HEALTHCHECK_ENABLED_' . $tree->id()] ?? false);
211
-                    $tree->setPreference(self::TREE_PREFERENCE_NAME, $tree_enabled ? '1' : '0');
212
-                }
213
-            }
214
-            return true;
215
-        } catch (Exception $ex) {
216
-            Log::addErrorLog(
217
-                sprintf(
218
-                    'Error while updating the Task schedule "%s". Exception: %s',
219
-                    $task_schedule->id(),
220
-                    $ex->getMessage()
221
-                )
222
-            );
223
-        }
224
-        return false;
225
-    }
208
+			foreach ($this->tree_service->all() as $tree) {
209
+				if (Auth::isManager($tree)) {
210
+					$tree_enabled = (bool) ($params['HEALTHCHECK_ENABLED_' . $tree->id()] ?? false);
211
+					$tree->setPreference(self::TREE_PREFERENCE_NAME, $tree_enabled ? '1' : '0');
212
+				}
213
+			}
214
+			return true;
215
+		} catch (Exception $ex) {
216
+			Log::addErrorLog(
217
+				sprintf(
218
+					'Error while updating the Task schedule "%s". Exception: %s',
219
+					$task_schedule->id(),
220
+					$ex->getMessage()
221
+				)
222
+			);
223
+		}
224
+		return false;
225
+	}
226 226
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Model/TaskSchedule.php 1 patch
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -25,290 +25,290 @@
 block discarded – undo
25 25
 class TaskSchedule
26 26
 {
27 27
     
28
-    /**
29
-     * Task Schedule ID
30
-     * @var int $id
31
-     */
32
-    private $id;
28
+	/**
29
+	 * Task Schedule ID
30
+	 * @var int $id
31
+	 */
32
+	private $id;
33 33
     
34
-    /**
35
-     * Task schedule status
36
-     * @var bool $enabled
37
-     */
38
-    private $enabled;
34
+	/**
35
+	 * Task schedule status
36
+	 * @var bool $enabled
37
+	 */
38
+	private $enabled;
39 39
     
40
-    /**
41
-     * ID of the task attached to schedule
42
-     * @var string $task_id
43
-     */
44
-    private $task_id;
40
+	/**
41
+	 * ID of the task attached to schedule
42
+	 * @var string $task_id
43
+	 */
44
+	private $task_id;
45 45
     
46
-    /**
47
-     * Last updated date
48
-     * @var Carbon $last_run
49
-     */
50
-    private $last_run;
46
+	/**
47
+	 * Last updated date
48
+	 * @var Carbon $last_run
49
+	 */
50
+	private $last_run;
51 51
     
52
-    /**
53
-     * Last run result
54
-     * @var bool $last_result
55
-     */
56
-    private $last_result;
52
+	/**
53
+	 * Last run result
54
+	 * @var bool $last_result
55
+	 */
56
+	private $last_result;
57 57
     
58
-    /**
59
-     * Task run frequency
60
-     * @var CarbonInterval $frequency
61
-     */
62
-    private $frequency;
58
+	/**
59
+	 * Task run frequency
60
+	 * @var CarbonInterval $frequency
61
+	 */
62
+	private $frequency;
63 63
     
64
-    /**
65
-     * Task remaining runs
66
-     * @var int $nb_occurrences
67
-     */
68
-    private $nb_occurrences;
64
+	/**
65
+	 * Task remaining runs
66
+	 * @var int $nb_occurrences
67
+	 */
68
+	private $nb_occurrences;
69 69
     
70
-    /**
71
-     * Current running status of the task
72
-     * @var bool $is_running
73
-     */
74
-    private $is_running;
70
+	/**
71
+	 * Current running status of the task
72
+	 * @var bool $is_running
73
+	 */
74
+	private $is_running;
75 75
     
76
-    /**
77
-     * Constructor for TaskSchedule
78
-     *
79
-     * @param int $id Schedule ID
80
-     * @param string $task_id Task ID
81
-     * @param bool $enabled Is the schedule enabled
82
-     * @param Carbon $last_run Last successful run date/time
83
-     * @param bool $last_result Result of the last run
84
-     * @param CarbonInterval $frequency Schedule frequency
85
-     * @param int $nb_occurrences Number of remaining occurrences to be run
86
-     * @param bool $is_running Is the task currently running
87
-     */
88
-    public function __construct(
89
-        int $id,
90
-        string $task_id,
91
-        bool $enabled,
92
-        Carbon $last_run,
93
-        bool $last_result,
94
-        CarbonInterval $frequency,
95
-        int $nb_occurrences,
96
-        bool $is_running
97
-    ) {
98
-        $this->id = $id;
99
-        $this->task_id = $task_id;
100
-        $this->enabled = $enabled;
101
-        $this->last_run = $last_run;
102
-        $this->last_result = $last_result;
103
-        $this->frequency = $frequency;
104
-        $this->nb_occurrences = $nb_occurrences;
105
-        $this->is_running = $is_running;
106
-    }
76
+	/**
77
+	 * Constructor for TaskSchedule
78
+	 *
79
+	 * @param int $id Schedule ID
80
+	 * @param string $task_id Task ID
81
+	 * @param bool $enabled Is the schedule enabled
82
+	 * @param Carbon $last_run Last successful run date/time
83
+	 * @param bool $last_result Result of the last run
84
+	 * @param CarbonInterval $frequency Schedule frequency
85
+	 * @param int $nb_occurrences Number of remaining occurrences to be run
86
+	 * @param bool $is_running Is the task currently running
87
+	 */
88
+	public function __construct(
89
+		int $id,
90
+		string $task_id,
91
+		bool $enabled,
92
+		Carbon $last_run,
93
+		bool $last_result,
94
+		CarbonInterval $frequency,
95
+		int $nb_occurrences,
96
+		bool $is_running
97
+	) {
98
+		$this->id = $id;
99
+		$this->task_id = $task_id;
100
+		$this->enabled = $enabled;
101
+		$this->last_run = $last_run;
102
+		$this->last_result = $last_result;
103
+		$this->frequency = $frequency;
104
+		$this->nb_occurrences = $nb_occurrences;
105
+		$this->is_running = $is_running;
106
+	}
107 107
     
108
-    /**
109
-     * Get the schedule ID.
110
-     *
111
-     * @return int
112
-     */
113
-    public function id(): int
114
-    {
115
-        return $this->id;
116
-    }
108
+	/**
109
+	 * Get the schedule ID.
110
+	 *
111
+	 * @return int
112
+	 */
113
+	public function id(): int
114
+	{
115
+		return $this->id;
116
+	}
117 117
     
118
-    /**
119
-     * Get the task ID.
120
-     *
121
-     * @return string
122
-     */
123
-    public function taskId(): string
124
-    {
125
-        return $this->task_id;
126
-    }
118
+	/**
119
+	 * Get the task ID.
120
+	 *
121
+	 * @return string
122
+	 */
123
+	public function taskId(): string
124
+	{
125
+		return $this->task_id;
126
+	}
127 127
     
128
-    /**
129
-     * Returns whether the schedule is enabled
130
-     *
131
-     * @return bool
132
-     */
133
-    public function isEnabled(): bool
134
-    {
135
-        return $this->enabled;
136
-    }
128
+	/**
129
+	 * Returns whether the schedule is enabled
130
+	 *
131
+	 * @return bool
132
+	 */
133
+	public function isEnabled(): bool
134
+	{
135
+		return $this->enabled;
136
+	}
137 137
     
138
-    /**
139
-     * Enable the schedule
140
-     *
141
-     * @return self
142
-     */
143
-    public function enable(): self
144
-    {
145
-        $this->enabled = true;
146
-        return $this;
147
-    }
138
+	/**
139
+	 * Enable the schedule
140
+	 *
141
+	 * @return self
142
+	 */
143
+	public function enable(): self
144
+	{
145
+		$this->enabled = true;
146
+		return $this;
147
+	}
148 148
     
149
-    /**
150
-     * Disable the schedule
151
-     *
152
-     * @return self
153
-     */
154
-    public function disable(): self
155
-    {
156
-        $this->enabled = false;
157
-        return $this;
158
-    }
149
+	/**
150
+	 * Disable the schedule
151
+	 *
152
+	 * @return self
153
+	 */
154
+	public function disable(): self
155
+	{
156
+		$this->enabled = false;
157
+		return $this;
158
+	}
159 159
     
160
-    /**
161
-     * Get the frequency of the schedule
162
-     *
163
-     * @return CarbonInterval
164
-     */
165
-    public function frequency(): CarbonInterval
166
-    {
167
-        return $this->frequency;
168
-    }
160
+	/**
161
+	 * Get the frequency of the schedule
162
+	 *
163
+	 * @return CarbonInterval
164
+	 */
165
+	public function frequency(): CarbonInterval
166
+	{
167
+		return $this->frequency;
168
+	}
169 169
     
170
-    /**
171
-     * Set the frequency of the schedule
172
-     *
173
-     * @param CarbonInterval $frequency
174
-     * @return self
175
-     */
176
-    public function setFrequency(CarbonInterval $frequency): self
177
-    {
178
-        $this->frequency = $frequency;
179
-        return $this;
180
-    }
170
+	/**
171
+	 * Set the frequency of the schedule
172
+	 *
173
+	 * @param CarbonInterval $frequency
174
+	 * @return self
175
+	 */
176
+	public function setFrequency(CarbonInterval $frequency): self
177
+	{
178
+		$this->frequency = $frequency;
179
+		return $this;
180
+	}
181 181
     
182
-    /**
183
-     * Get the date/time of the last successful run.
184
-     *
185
-     * @return Carbon
186
-     */
187
-    public function lastRunTime(): Carbon
188
-    {
189
-        return $this->last_run;
190
-    }
182
+	/**
183
+	 * Get the date/time of the last successful run.
184
+	 *
185
+	 * @return Carbon
186
+	 */
187
+	public function lastRunTime(): Carbon
188
+	{
189
+		return $this->last_run;
190
+	}
191 191
     
192
-    /**
193
-     * Set the last successful run date/time
194
-     *
195
-     * @param Carbon $last_run
196
-     * @return self
197
-     */
198
-    public function setLastRunTime(Carbon $last_run): self
199
-    {
200
-        $this->last_run = $last_run;
201
-        return $this;
202
-    }
192
+	/**
193
+	 * Set the last successful run date/time
194
+	 *
195
+	 * @param Carbon $last_run
196
+	 * @return self
197
+	 */
198
+	public function setLastRunTime(Carbon $last_run): self
199
+	{
200
+		$this->last_run = $last_run;
201
+		return $this;
202
+	}
203 203
     
204
-    /**
205
-     * Returns whether the last run was successful
206
-     *
207
-     * @return bool
208
-     */
209
-    public function wasLastRunSuccess(): bool
210
-    {
211
-        return $this->last_result;
212
-    }
204
+	/**
205
+	 * Returns whether the last run was successful
206
+	 *
207
+	 * @return bool
208
+	 */
209
+	public function wasLastRunSuccess(): bool
210
+	{
211
+		return $this->last_result;
212
+	}
213 213
 
214
-    /**
215
-     * Set the last run result
216
-     *
217
-     * @param bool $last_result
218
-     * @return self
219
-     */
220
-    public function setLastResult(bool $last_result): self
221
-    {
222
-        $this->last_result = $last_result;
223
-        return $this;
224
-    }
214
+	/**
215
+	 * Set the last run result
216
+	 *
217
+	 * @param bool $last_result
218
+	 * @return self
219
+	 */
220
+	public function setLastResult(bool $last_result): self
221
+	{
222
+		$this->last_result = $last_result;
223
+		return $this;
224
+	}
225 225
     
226
-    /**
227
-     * Get the number of remaining of occurrences of task runs.
228
-     * Returns 0 if the tasks must be run indefinitely.
229
-     *
230
-     * @return int
231
-     */
232
-    public function remainingOccurences(): int
233
-    {
234
-        return $this->nb_occurrences;
235
-    }
226
+	/**
227
+	 * Get the number of remaining of occurrences of task runs.
228
+	 * Returns 0 if the tasks must be run indefinitely.
229
+	 *
230
+	 * @return int
231
+	 */
232
+	public function remainingOccurences(): int
233
+	{
234
+		return $this->nb_occurrences;
235
+	}
236 236
     
237
-    /**
238
-     * Decrements the number of remaining occurences by 1.
239
-     * The task will be disabled when the number reaches 0.
240
-     *
241
-     * @return self
242
-     */
243
-    public function decrementRemainingOccurences(): self
244
-    {
245
-        if ($this->nb_occurrences > 0) {
246
-            $this->nb_occurrences--;
247
-            if ($this->nb_occurrences == 0) {
248
-                $this->disable();
249
-            }
250
-        }
251
-        return $this;
252
-    }
237
+	/**
238
+	 * Decrements the number of remaining occurences by 1.
239
+	 * The task will be disabled when the number reaches 0.
240
+	 *
241
+	 * @return self
242
+	 */
243
+	public function decrementRemainingOccurences(): self
244
+	{
245
+		if ($this->nb_occurrences > 0) {
246
+			$this->nb_occurrences--;
247
+			if ($this->nb_occurrences == 0) {
248
+				$this->disable();
249
+			}
250
+		}
251
+		return $this;
252
+	}
253 253
     
254
-    /**
255
-     * Set the number of remaining occurences of task runs.
256
-     *
257
-     * @param int $nb_occurrences
258
-     * @return self
259
-     */
260
-    public function setRemainingOccurences(int $nb_occurrences): self
261
-    {
262
-        $this->nb_occurrences = $nb_occurrences;
263
-        return $this;
264
-    }
254
+	/**
255
+	 * Set the number of remaining occurences of task runs.
256
+	 *
257
+	 * @param int $nb_occurrences
258
+	 * @return self
259
+	 */
260
+	public function setRemainingOccurences(int $nb_occurrences): self
261
+	{
262
+		$this->nb_occurrences = $nb_occurrences;
263
+		return $this;
264
+	}
265 265
     
266
-    /**
267
-     * Returns whether the task is running
268
-     * @return bool
269
-     */
270
-    public function isRunning(): bool
271
-    {
272
-        return $this->is_running;
273
-    }
266
+	/**
267
+	 * Returns whether the task is running
268
+	 * @return bool
269
+	 */
270
+	public function isRunning(): bool
271
+	{
272
+		return $this->is_running;
273
+	}
274 274
     
275
-    /**
276
-     * Informs the schedule that the task is going to run
277
-     *
278
-     * @return self
279
-     */
280
-    public function startRunning(): self
281
-    {
282
-        $this->is_running = true;
283
-        return $this;
284
-    }
275
+	/**
276
+	 * Informs the schedule that the task is going to run
277
+	 *
278
+	 * @return self
279
+	 */
280
+	public function startRunning(): self
281
+	{
282
+		$this->is_running = true;
283
+		return $this;
284
+	}
285 285
     
286
-    /**
287
-     * Informs the schedule that the task has stopped running.
288
-     * @return self
289
-     */
290
-    public function stopRunning(): self
291
-    {
292
-        $this->is_running = false;
293
-        return $this;
294
-    }
286
+	/**
287
+	 * Informs the schedule that the task has stopped running.
288
+	 * @return self
289
+	 */
290
+	public function stopRunning(): self
291
+	{
292
+		$this->is_running = false;
293
+		return $this;
294
+	}
295 295
     
296
-    /**
297
-     * Returns the schedule details as an associate array
298
-     *
299
-     * @return array
300
-     */
301
-    public function toArray(): array
302
-    {
303
-        return [
304
-            'id'            =>  $this->id,
305
-            'task_id'       =>  $this->task_id,
306
-            'enabled'       =>  $this->enabled,
307
-            'last_run'      =>  $this->last_run,
308
-            'last_result'   =>  $this->last_result,
309
-            'frequency'     =>  $this->frequency,
310
-            'nb_occurrences' =>  $this->nb_occurrences,
311
-            'is_running'    =>  $this->is_running
312
-        ];
313
-    }
296
+	/**
297
+	 * Returns the schedule details as an associate array
298
+	 *
299
+	 * @return array
300
+	 */
301
+	public function toArray(): array
302
+	{
303
+		return [
304
+			'id'            =>  $this->id,
305
+			'task_id'       =>  $this->task_id,
306
+			'enabled'       =>  $this->enabled,
307
+			'last_run'      =>  $this->last_run,
308
+			'last_result'   =>  $this->last_result,
309
+			'frequency'     =>  $this->frequency,
310
+			'nb_occurrences' =>  $this->nb_occurrences,
311
+			'is_running'    =>  $this->is_running
312
+		];
313
+	}
314 314
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Schema/Migration1.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -25,25 +25,25 @@
 block discarded – undo
25 25
 class Migration1 implements MigrationInterface
26 26
 {
27 27
     
28
-    /**
29
-     * {@inheritDoc}
30
-     * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
31
-     */
32
-    public function upgrade(): void
33
-    {
34
-        // Clean up previous admin tasks table if it exists
35
-        DB::schema()->dropIfExists('maj_admintasks');
28
+	/**
29
+	 * {@inheritDoc}
30
+	 * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
31
+	 */
32
+	public function upgrade(): void
33
+	{
34
+		// Clean up previous admin tasks table if it exists
35
+		DB::schema()->dropIfExists('maj_admintasks');
36 36
         
37
-        DB::schema()->create('maj_admintasks', static function (Blueprint $table): void {
37
+		DB::schema()->create('maj_admintasks', static function (Blueprint $table): void {
38 38
 
39
-            $table->increments('majat_id');
40
-            $table->string('majat_task_id', 32)->unique()->nullable(false);
41
-            $table->enum('majat_status', ['enabled', 'disabled'])->nullable(false)->default('disabled');
42
-            $table->dateTime('majat_last_run')->nullable(false)->default(Carbon::createFromTimestampUTC(0));
43
-            $table->boolean('majat_last_result')->nullable(false)->default(true);
44
-            $table->integer('majat_frequency')->nullable(false)->default(10080);
45
-            $table->smallInteger('majat_nb_occur')->nullable(false)->default(0);
46
-            $table->boolean('majat_running')->nullable(false)->default(false);
47
-        });
48
-    }
39
+			$table->increments('majat_id');
40
+			$table->string('majat_task_id', 32)->unique()->nullable(false);
41
+			$table->enum('majat_status', ['enabled', 'disabled'])->nullable(false)->default('disabled');
42
+			$table->dateTime('majat_last_run')->nullable(false)->default(Carbon::createFromTimestampUTC(0));
43
+			$table->boolean('majat_last_result')->nullable(false)->default(true);
44
+			$table->integer('majat_frequency')->nullable(false)->default(10080);
45
+			$table->smallInteger('majat_nb_occur')->nullable(false)->default(0);
46
+			$table->boolean('majat_running')->nullable(false)->default(false);
47
+		});
48
+	}
49 49
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Schema/Migration0.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@
 block discarded – undo
22 22
 class Migration0 implements MigrationInterface
23 23
 {
24 24
     
25
-    /**
26
-     * {@inheritDoc}
27
-     * @see MigrationInterface::upgrade()
28
-     */
29
-    public function upgrade(): void
30
-    {
31
-        // These migrations have been merged into migration 1.
32
-    }
25
+	/**
26
+	 * {@inheritDoc}
27
+	 * @see MigrationInterface::upgrade()
28
+	 */
29
+	public function upgrade(): void
30
+	{
31
+		// These migrations have been merged into migration 1.
32
+	}
33 33
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/WelcomeBlock/Services/MatomoStatsService.php 1 patch
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -29,97 +29,97 @@
 block discarded – undo
29 29
 class MatomoStatsService
30 30
 {
31 31
     
32
-    /**
33
-     * Returns the number of visits for the current year (up to the day before).
34
-     * That statistic is cached for the day, to avoid unecessary calls to Matomo API.
35
-     *
36
-     * @param WelcomeBlockModule $module
37
-     * @param int $block_id
38
-     * @return int|NULL
39
-     */
40
-    public function visitsThisYear(WelcomeBlockModule $module, int $block_id): ?int
41
-    {
42
-        /** @var Cache $cache */
43
-        $cache = app('cache.files');
44
-        assert($cache instanceof Cache);
32
+	/**
33
+	 * Returns the number of visits for the current year (up to the day before).
34
+	 * That statistic is cached for the day, to avoid unecessary calls to Matomo API.
35
+	 *
36
+	 * @param WelcomeBlockModule $module
37
+	 * @param int $block_id
38
+	 * @return int|NULL
39
+	 */
40
+	public function visitsThisYear(WelcomeBlockModule $module, int $block_id): ?int
41
+	{
42
+		/** @var Cache $cache */
43
+		$cache = app('cache.files');
44
+		assert($cache instanceof Cache);
45 45
         
46
-        return $cache->remember(
47
-            $module->name() . '-matomovisits-yearly-' . $block_id,
48
-            function () use ($module, $block_id): ?int {
49
-                $visits_year = $this->visits($module, $block_id, 'year');
50
-                if ($visits_year === null) {
51
-                    return null;
52
-                }
53
-                $visits_today = $this->visits($module, $block_id, 'day');
46
+		return $cache->remember(
47
+			$module->name() . '-matomovisits-yearly-' . $block_id,
48
+			function () use ($module, $block_id): ?int {
49
+				$visits_year = $this->visits($module, $block_id, 'year');
50
+				if ($visits_year === null) {
51
+					return null;
52
+				}
53
+				$visits_today = $this->visits($module, $block_id, 'day');
54 54
                 
55
-                return $visits_year - $visits_today;
56
-            },
57
-            Carbon::now()->addDay()->startOfDay()->diffInSeconds(Carbon::now()) // Valid until midnight
58
-        );
59
-    }
55
+				return $visits_year - $visits_today;
56
+			},
57
+			Carbon::now()->addDay()->startOfDay()->diffInSeconds(Carbon::now()) // Valid until midnight
58
+		);
59
+	}
60 60
     
61
-    /**
62
-     * Returns the number of visits for the current day.
63
-     *
64
-     * @param WelcomeBlockModule $module
65
-     * @param int $block_id
66
-     * @return int|NULL
67
-     */
68
-    public function visitsToday(WelcomeBlockModule $module, int $block_id): ?int
69
-    {
70
-        return app('cache.array')->remember(
71
-            $module->name() . '-matomovisits-daily-' . $block_id,
72
-            function () use ($module, $block_id): ?int {
73
-                return $this->visits($module, $block_id, 'day');
74
-            }
75
-        );
76
-    }
61
+	/**
62
+	 * Returns the number of visits for the current day.
63
+	 *
64
+	 * @param WelcomeBlockModule $module
65
+	 * @param int $block_id
66
+	 * @return int|NULL
67
+	 */
68
+	public function visitsToday(WelcomeBlockModule $module, int $block_id): ?int
69
+	{
70
+		return app('cache.array')->remember(
71
+			$module->name() . '-matomovisits-daily-' . $block_id,
72
+			function () use ($module, $block_id): ?int {
73
+				return $this->visits($module, $block_id, 'day');
74
+			}
75
+		);
76
+	}
77 77
     
78
-    /**
79
-     * Invoke the Matomo API to retrieve the number of visits over a period.
80
-     *
81
-     * @param WelcomeBlockModule $module
82
-     * @param int $block_id
83
-     * @param string $period
84
-     * @return int|NULL
85
-     */
86
-    protected function visits(WelcomeBlockModule $module, int $block_id, string $period): ?int
87
-    {
88
-        $settings = $module->matomoSettings($block_id);
78
+	/**
79
+	 * Invoke the Matomo API to retrieve the number of visits over a period.
80
+	 *
81
+	 * @param WelcomeBlockModule $module
82
+	 * @param int $block_id
83
+	 * @param string $period
84
+	 * @return int|NULL
85
+	 */
86
+	protected function visits(WelcomeBlockModule $module, int $block_id, string $period): ?int
87
+	{
88
+		$settings = $module->matomoSettings($block_id);
89 89
         
90
-        if (
91
-            $settings['matomo_enabled'] === true
92
-            && mb_strlen($settings['matomo_url']) > 0
93
-            && mb_strlen($settings['matomo_token']) > 0
94
-            && $settings['matomo_siteid'] > 0
95
-        ) {
96
-            try {
97
-                $http_client = new Client([
98
-                    RequestOptions::TIMEOUT => 30
99
-                ]);
90
+		if (
91
+			$settings['matomo_enabled'] === true
92
+			&& mb_strlen($settings['matomo_url']) > 0
93
+			&& mb_strlen($settings['matomo_token']) > 0
94
+			&& $settings['matomo_siteid'] > 0
95
+		) {
96
+			try {
97
+				$http_client = new Client([
98
+					RequestOptions::TIMEOUT => 30
99
+				]);
100 100
                 
101
-                $response = $http_client->get($settings['matomo_url'], [
102
-                    'query' =>  [
103
-                        'module'    =>  'API',
104
-                        'method'    =>  'VisitsSummary.getVisits',
105
-                        'idSite'    =>  $settings['matomo_siteid'],
106
-                        'period'    =>  $period,
107
-                        'date'      =>  'today',
108
-                        'token_auth' =>  $settings['matomo_token'],
109
-                        'format'    =>  'json'
110
-                    ]
111
-                ]);
101
+				$response = $http_client->get($settings['matomo_url'], [
102
+					'query' =>  [
103
+						'module'    =>  'API',
104
+						'method'    =>  'VisitsSummary.getVisits',
105
+						'idSite'    =>  $settings['matomo_siteid'],
106
+						'period'    =>  $period,
107
+						'date'      =>  'today',
108
+						'token_auth' =>  $settings['matomo_token'],
109
+						'format'    =>  'json'
110
+					]
111
+				]);
112 112
                 
113
-                if ($response->getStatusCode() === StatusCodeInterface::STATUS_OK) {
114
-                    $result = json_decode((string) $response->getBody(), true)['value'] ?? null;
115
-                    if ($result !== null) {
116
-                        return (int)$result;
117
-                    }
118
-                }
119
-            } catch (RequestException $ex) {
120
-            }
121
-        }
113
+				if ($response->getStatusCode() === StatusCodeInterface::STATUS_OK) {
114
+					$result = json_decode((string) $response->getBody(), true)['value'] ?? null;
115
+					if ($result !== null) {
116
+						return (int)$result;
117
+					}
118
+				}
119
+			} catch (RequestException $ex) {
120
+			}
121
+		}
122 122
         
123
-        return null;
124
-    }
123
+		return null;
124
+	}
125 125
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/WelcomeBlock/WelcomeBlockModule.php 1 patch
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -30,148 +30,148 @@
 block discarded – undo
30 30
  */
31 31
 class WelcomeBlockModule extends AbstractModuleMaj implements ModuleBlockInterface
32 32
 {
33
-    use ModuleBlockTrait;
33
+	use ModuleBlockTrait;
34 34
 
35
-    /**
36
-     * {@inheritDoc}
37
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
38
-     */
39
-    public function title(): string
40
-    {
41
-        return /* I18N: Name of the “WelcomeBlock” module */ I18N::translate('MyArtJaub Welcome Block');
42
-    }
35
+	/**
36
+	 * {@inheritDoc}
37
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
38
+	 */
39
+	public function title(): string
40
+	{
41
+		return /* I18N: Name of the “WelcomeBlock” module */ I18N::translate('MyArtJaub Welcome Block');
42
+	}
43 43
     
44
-    /**
45
-     * {@inheritDoc}
46
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
47
-     */
48
-    public function description(): string
49
-    {
50
-        //phpcs:ignore Generic.Files.LineLength.TooLong
51
-        return /* I18N: Description of the “WelcomeBlock” module */ I18N::translate('The MyArtJaub Welcome block welcomes the visitor to the site, allows a quick login to the site, and displays statistics on visits.');
52
-    }
44
+	/**
45
+	 * {@inheritDoc}
46
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
47
+	 */
48
+	public function description(): string
49
+	{
50
+		//phpcs:ignore Generic.Files.LineLength.TooLong
51
+		return /* I18N: Description of the “WelcomeBlock” module */ I18N::translate('The MyArtJaub Welcome block welcomes the visitor to the site, allows a quick login to the site, and displays statistics on visits.');
52
+	}
53 53
     
54
-    /**
55
-     * {@inheritDoc}
56
-     * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::loadRoutes()
57
-     */
58
-    public function loadRoutes(Map $router): void
59
-    {
60
-        $router->attach('', '', static function (Map $router) {
54
+	/**
55
+	 * {@inheritDoc}
56
+	 * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::loadRoutes()
57
+	 */
58
+	public function loadRoutes(Map $router): void
59
+	{
60
+		$router->attach('', '', static function (Map $router) {
61 61
 
62
-            $router->attach('', '/module-maj/welcomeblock/{block_id}', static function (Map $router) {
62
+			$router->attach('', '/module-maj/welcomeblock/{block_id}', static function (Map $router) {
63 63
                 
64
-                $router->get(MatomoStats::class, '/matomostats', MatomoStats::class);
65
-            });
66
-        });
67
-    }
64
+				$router->get(MatomoStats::class, '/matomostats', MatomoStats::class);
65
+			});
66
+		});
67
+	}
68 68
     
69
-    /**
70
-     * {@inheritDoc}
71
-     * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::getBlock()
72
-     */
73
-    public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string
74
-    {
75
-        $fab_welcome_block_view = app(\Fisharebest\Webtrees\Module\WelcomeBlockModule::class)
76
-            ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED);
69
+	/**
70
+	 * {@inheritDoc}
71
+	 * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::getBlock()
72
+	 */
73
+	public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string
74
+	{
75
+		$fab_welcome_block_view = app(\Fisharebest\Webtrees\Module\WelcomeBlockModule::class)
76
+			->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED);
77 77
         
78
-        $fab_login_block_view = app(\Fisharebest\Webtrees\Module\LoginBlockModule::class)
79
-            ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED);
78
+		$fab_login_block_view = app(\Fisharebest\Webtrees\Module\LoginBlockModule::class)
79
+			->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED);
80 80
         
81
-        $content = view($this->name() . '::block-embed', [
82
-            'block_id'                  =>  $block_id,
83
-            'fab_welcome_block_view'    =>  $fab_welcome_block_view,
84
-            'fab_login_block_view'      =>  $fab_login_block_view,
85
-            'matomo_enabled'            =>  $this->isMatomoEnabled($block_id)
86
-        ]);
81
+		$content = view($this->name() . '::block-embed', [
82
+			'block_id'                  =>  $block_id,
83
+			'fab_welcome_block_view'    =>  $fab_welcome_block_view,
84
+			'fab_login_block_view'      =>  $fab_login_block_view,
85
+			'matomo_enabled'            =>  $this->isMatomoEnabled($block_id)
86
+		]);
87 87
         
88
-        if ($context !== self::CONTEXT_EMBED) {
89
-            return view('modules/block-template', [
90
-                'block'      => Str::kebab($this->name()),
91
-                'id'         => $block_id,
92
-                'config_url' => $this->configUrl($tree, $context, $block_id),
93
-                'title'      => $tree->title(),
94
-                'content'    => $content,
95
-            ]);
96
-        }
88
+		if ($context !== self::CONTEXT_EMBED) {
89
+			return view('modules/block-template', [
90
+				'block'      => Str::kebab($this->name()),
91
+				'id'         => $block_id,
92
+				'config_url' => $this->configUrl($tree, $context, $block_id),
93
+				'title'      => $tree->title(),
94
+				'content'    => $content,
95
+			]);
96
+		}
97 97
         
98
-        return $content;
99
-    }
98
+		return $content;
99
+	}
100 100
     
101
-    /**
102
-     * {@inheritDoc}
103
-     * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::isTreeBlock()
104
-     */
105
-    public function isTreeBlock(): bool
106
-    {
107
-        return true;
108
-    }
101
+	/**
102
+	 * {@inheritDoc}
103
+	 * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::isTreeBlock()
104
+	 */
105
+	public function isTreeBlock(): bool
106
+	{
107
+		return true;
108
+	}
109 109
     
110
-    /**
111
-     * {@inheritDoc}
112
-     * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::editBlockConfiguration()
113
-     */
114
-    public function editBlockConfiguration(Tree $tree, int $block_id): string
115
-    {
116
-        return view($this->name() . '::config', $this->matomoSettings($block_id));
117
-    }
110
+	/**
111
+	 * {@inheritDoc}
112
+	 * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::editBlockConfiguration()
113
+	 */
114
+	public function editBlockConfiguration(Tree $tree, int $block_id): string
115
+	{
116
+		return view($this->name() . '::config', $this->matomoSettings($block_id));
117
+	}
118 118
     
119
-    /**
120
-     * {@inheritDoc}
121
-     * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::saveBlockConfiguration()
122
-     */
123
-    public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void
124
-    {
125
-        $params = (array) $request->getParsedBody();
119
+	/**
120
+	 * {@inheritDoc}
121
+	 * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::saveBlockConfiguration()
122
+	 */
123
+	public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void
124
+	{
125
+		$params = (array) $request->getParsedBody();
126 126
         
127
-        $matomo_enabled = $params['matomo_enabled'] == 'yes';
128
-        $this->setBlockSetting($block_id, 'matomo_enabled', $matomo_enabled ? 'yes' : 'no');
129
-        if (!$matomo_enabled) {
130
-            return;
131
-        }
127
+		$matomo_enabled = $params['matomo_enabled'] == 'yes';
128
+		$this->setBlockSetting($block_id, 'matomo_enabled', $matomo_enabled ? 'yes' : 'no');
129
+		if (!$matomo_enabled) {
130
+			return;
131
+		}
132 132
         
133
-        if (filter_var($params['matomo_url'], FILTER_VALIDATE_URL) === false) {
134
-            FlashMessages::addMessage(I18N::translate('The Matomo URL provided is not valid.'), 'danger');
135
-            return;
136
-        }
133
+		if (filter_var($params['matomo_url'], FILTER_VALIDATE_URL) === false) {
134
+			FlashMessages::addMessage(I18N::translate('The Matomo URL provided is not valid.'), 'danger');
135
+			return;
136
+		}
137 137
         
138
-        if (filter_var($params['matomo_siteid'], FILTER_VALIDATE_INT) === false) {
139
-            FlashMessages::addMessage(I18N::translate('The Matomo Site ID provided is not valid.'), 'danger');
140
-            return;
141
-        }
138
+		if (filter_var($params['matomo_siteid'], FILTER_VALIDATE_INT) === false) {
139
+			FlashMessages::addMessage(I18N::translate('The Matomo Site ID provided is not valid.'), 'danger');
140
+			return;
141
+		}
142 142
         
143
-        $this
144
-            ->setBlockSetting($block_id, 'matomo_url', trim($params['matomo_url']))
145
-            ->setBlockSetting($block_id, 'matomo_token', trim($params['matomo_token']))
146
-            ->setBlockSetting($block_id, 'matomo_siteid', $params['matomo_siteid']);
143
+		$this
144
+			->setBlockSetting($block_id, 'matomo_url', trim($params['matomo_url']))
145
+			->setBlockSetting($block_id, 'matomo_token', trim($params['matomo_token']))
146
+			->setBlockSetting($block_id, 'matomo_siteid', $params['matomo_siteid']);
147 147
         
148
-        app('cache.files')->forget($this->name() . '-matomovisits-yearly-' . $block_id);
149
-    }
148
+		app('cache.files')->forget($this->name() . '-matomovisits-yearly-' . $block_id);
149
+	}
150 150
     
151
-    /**
152
-     * Returns whether Matomo statistics is enabled for a specific MyArtJaub WelcomeBlock block
153
-     *
154
-     * @param int $block_id
155
-     * @return bool
156
-     */
157
-    public function isMatomoEnabled(int $block_id): bool
158
-    {
159
-        return $this->getBlockSetting($block_id, 'matomo_enabled', 'no') === 'yes';
160
-    }
151
+	/**
152
+	 * Returns whether Matomo statistics is enabled for a specific MyArtJaub WelcomeBlock block
153
+	 *
154
+	 * @param int $block_id
155
+	 * @return bool
156
+	 */
157
+	public function isMatomoEnabled(int $block_id): bool
158
+	{
159
+		return $this->getBlockSetting($block_id, 'matomo_enabled', 'no') === 'yes';
160
+	}
161 161
     
162
-    /**
163
-     * Returns settings for retrieving Matomo statistics for a specific MyArtJaub WelcomeBlock block
164
-     *
165
-     * @param int $block_id
166
-     * @return array<string, mixed>
167
-     */
168
-    public function matomoSettings(int $block_id): array
169
-    {
170
-        return [
171
-            'matomo_enabled' => $this->isMatomoEnabled($block_id),
172
-            'matomo_url' => $this->getBlockSetting($block_id, 'matomo_url'),
173
-            'matomo_token' => $this->getBlockSetting($block_id, 'matomo_token'),
174
-            'matomo_siteid'  => (int) $this->getBlockSetting($block_id, 'matomo_siteid', '0')
175
-        ];
176
-    }
162
+	/**
163
+	 * Returns settings for retrieving Matomo statistics for a specific MyArtJaub WelcomeBlock block
164
+	 *
165
+	 * @param int $block_id
166
+	 * @return array<string, mixed>
167
+	 */
168
+	public function matomoSettings(int $block_id): array
169
+	{
170
+		return [
171
+			'matomo_enabled' => $this->isMatomoEnabled($block_id),
172
+			'matomo_url' => $this->getBlockSetting($block_id, 'matomo_url'),
173
+			'matomo_token' => $this->getBlockSetting($block_id, 'matomo_token'),
174
+			'matomo_siteid'  => (int) $this->getBlockSetting($block_id, 'matomo_siteid', '0')
175
+		];
176
+	}
177 177
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/WelcomeBlock/Http/RequestHandlers/MatomoStats.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -27,50 +27,50 @@
 block discarded – undo
27 27
  */
28 28
 class MatomoStats implements RequestHandlerInterface
29 29
 {
30
-    use ViewResponseTrait;
30
+	use ViewResponseTrait;
31 31
     
32
-    /**
33
-     * @var WelcomeBlockModule
34
-     */
35
-    private $module;
32
+	/**
33
+	 * @var WelcomeBlockModule
34
+	 */
35
+	private $module;
36 36
     
37
-    /**
38
-     * @var MatomoStatsService $matomo_service
39
-     */
40
-    private $matomo_service;
37
+	/**
38
+	 * @var MatomoStatsService $matomo_service
39
+	 */
40
+	private $matomo_service;
41 41
 
42
-    /**
43
-     * Constructor for MatomoStats request handler
44
-     * @param ModuleService $module_service
45
-     * @param MatomoStatsService $matomo_service
46
-     */
47
-    public function __construct(
48
-        ModuleService $module_service,
49
-        MatomoStatsService $matomo_service
50
-    ) {
51
-        $this->module = $module_service->findByInterface(WelcomeBlockModule::class)->first();
52
-        $this->matomo_service = $matomo_service;
53
-    }
42
+	/**
43
+	 * Constructor for MatomoStats request handler
44
+	 * @param ModuleService $module_service
45
+	 * @param MatomoStatsService $matomo_service
46
+	 */
47
+	public function __construct(
48
+		ModuleService $module_service,
49
+		MatomoStatsService $matomo_service
50
+	) {
51
+		$this->module = $module_service->findByInterface(WelcomeBlockModule::class)->first();
52
+		$this->matomo_service = $matomo_service;
53
+	}
54 54
 
55
-    /**
56
-     * {@inheritDoc}
57
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
58
-     */
59
-    public function handle(ServerRequestInterface $request): ResponseInterface
60
-    {
61
-        $this->layout = 'layouts/ajax';
55
+	/**
56
+	 * {@inheritDoc}
57
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
58
+	 */
59
+	public function handle(ServerRequestInterface $request): ResponseInterface
60
+	{
61
+		$this->layout = 'layouts/ajax';
62 62
         
63
-        $block_id = filter_var($request->getAttribute('block_id'), FILTER_VALIDATE_INT);
64
-        $nb_visits_year = $nb_visits_today = null;
63
+		$block_id = filter_var($request->getAttribute('block_id'), FILTER_VALIDATE_INT);
64
+		$nb_visits_year = $nb_visits_today = null;
65 65
         
66
-        if ($block_id !== false && $this->module->isMatomoEnabled($block_id)) {
67
-            $nb_visits_today = $this->matomo_service->visitsToday($this->module, (int) $block_id);
68
-            $nb_visits_year = $this->matomo_service->visitsThisYear($this->module, (int) $block_id) + $nb_visits_today;
69
-        }
66
+		if ($block_id !== false && $this->module->isMatomoEnabled($block_id)) {
67
+			$nb_visits_today = $this->matomo_service->visitsToday($this->module, (int) $block_id);
68
+			$nb_visits_year = $this->matomo_service->visitsThisYear($this->module, (int) $block_id) + $nb_visits_today;
69
+		}
70 70
         
71
-        return $this->viewResponse($this->module->name() . '::matomo-stats', [
72
-            'visits_year'   =>  $nb_visits_year,
73
-            'visits_today'  =>  $nb_visits_today
74
-        ]);
75
-    }
71
+		return $this->viewResponse($this->module->name() . '::matomo-stats', [
72
+			'visits_year'   =>  $nb_visits_year,
73
+			'visits_today'  =>  $nb_visits_today
74
+		]);
75
+	}
76 76
 }
Please login to merge, or discard this patch.