Passed
Push — feature/code-analysis ( 4fe35d...c99b5b )
by Jonathan
11:08 queued 07:29
created
app/Module/Sosa/Services/SosaRecordsService.php 1 patch
Indentation   +272 added lines, -272 removed lines patch added patch discarded remove patch
@@ -30,291 +30,291 @@
 block discarded – undo
30 30
  */
31 31
 class SosaRecordsService
32 32
 {
33
-    private ?int $max_system_generations = null;
33
+	private ?int $max_system_generations = null;
34 34
 
35
-    /**
36
-     * Maximum number of generation the system is able to hold.
37
-     * This is based on the size of the bigint SQL type (2^63) and the maximum PHP integer type
38
-     *
39
-     * @return int
40
-     */
41
-    public function maxSystemGenerations(): int
42
-    {
43
-        if ($this->max_system_generations === null) {
44
-            $this->max_system_generations = min(63, $this->generation(PHP_INT_MAX));
45
-        }
46
-        return $this->max_system_generations;
47
-    }
35
+	/**
36
+	 * Maximum number of generation the system is able to hold.
37
+	 * This is based on the size of the bigint SQL type (2^63) and the maximum PHP integer type
38
+	 *
39
+	 * @return int
40
+	 */
41
+	public function maxSystemGenerations(): int
42
+	{
43
+		if ($this->max_system_generations === null) {
44
+			$this->max_system_generations = min(63, $this->generation(PHP_INT_MAX));
45
+		}
46
+		return $this->max_system_generations;
47
+	}
48 48
 
49
-    /**
50
-     * Calculate the generation of a sosa
51
-     * Sosa 1 is of generation 1.
52
-     *
53
-     * @param int $sosa
54
-     * @return int
55
-     */
56
-    public function generation(int $sosa): int
57
-    {
58
-        return BigInteger::of($sosa)->getBitLength();
59
-    }
49
+	/**
50
+	 * Calculate the generation of a sosa
51
+	 * Sosa 1 is of generation 1.
52
+	 *
53
+	 * @param int $sosa
54
+	 * @return int
55
+	 */
56
+	public function generation(int $sosa): int
57
+	{
58
+		return BigInteger::of($sosa)->getBitLength();
59
+	}
60 60
 
61
-    /**
62
-     * Calculate the descendant sosa of the given sosa, at the given generation.
63
-     * For instance, the descendant of the Sosa 14 at generation 2 is Sosa 3 (mother).
64
-     *
65
-     * @param int $sosa
66
-     * @param int $gen
67
-     * @return int
68
-     */
69
-    public function sosaDescendantOf(int $sosa, int $gen): int
70
-    {
71
-        $gen_sosa = $this->generation($sosa);
72
-        return $gen_sosa <= $gen ? $sosa : BigInteger::of($sosa)
73
-            ->dividedBy(BigInteger::of(2)->power($this->generation($sosa) - $gen), RoundingMode::DOWN)
74
-            ->toInt();
75
-    }
61
+	/**
62
+	 * Calculate the descendant sosa of the given sosa, at the given generation.
63
+	 * For instance, the descendant of the Sosa 14 at generation 2 is Sosa 3 (mother).
64
+	 *
65
+	 * @param int $sosa
66
+	 * @param int $gen
67
+	 * @return int
68
+	 */
69
+	public function sosaDescendantOf(int $sosa, int $gen): int
70
+	{
71
+		$gen_sosa = $this->generation($sosa);
72
+		return $gen_sosa <= $gen ? $sosa : BigInteger::of($sosa)
73
+			->dividedBy(BigInteger::of(2)->power($this->generation($sosa) - $gen), RoundingMode::DOWN)
74
+			->toInt();
75
+	}
76 76
 
77
-    /**
78
-     * Check whether an individual is a Sosa ancestor.
79
-     *
80
-     * @param Tree $tree
81
-     * @param UserInterface $user
82
-     * @param Individual $indi
83
-     * @return bool
84
-     */
85
-    public function isSosa(Tree $tree, UserInterface $user, Individual $indi): bool
86
-    {
87
-        return $this->sosaNumbers($tree, $user, $indi)->count() > 0;
88
-    }
77
+	/**
78
+	 * Check whether an individual is a Sosa ancestor.
79
+	 *
80
+	 * @param Tree $tree
81
+	 * @param UserInterface $user
82
+	 * @param Individual $indi
83
+	 * @return bool
84
+	 */
85
+	public function isSosa(Tree $tree, UserInterface $user, Individual $indi): bool
86
+	{
87
+		return $this->sosaNumbers($tree, $user, $indi)->count() > 0;
88
+	}
89 89
 
90
-    /**
91
-     * Returns all Sosa numbers associated to an Individual
92
-     *
93
-     * @param Tree $tree
94
-     * @param UserInterface $user
95
-     * @param Individual $indi
96
-     * @return Collection<int, int>
97
-     */
98
-    public function sosaNumbers(Tree $tree, UserInterface $user, Individual $indi): Collection
99
-    {
100
-        return Registry::cache()->array()->remember(
101
-            'sosanumbers-' . $indi->xref() . '@' . $tree->id() . '-' . $user->id(),
102
-            function () use ($tree, $user, $indi): Collection {
103
-                return DB::table('maj_sosa')
104
-                    ->select(['majs_sosa', 'majs_gen'])
105
-                    ->where('majs_gedcom_id', '=', $tree->id())
106
-                    ->where('majs_user_id', '=', $user->id())
107
-                    ->where('majs_i_id', '=', $indi->xref())
108
-                    ->orderBy('majs_sosa')
109
-                    ->get()->pluck('majs_gen', 'majs_sosa');
110
-            }
111
-        );
112
-    }
90
+	/**
91
+	 * Returns all Sosa numbers associated to an Individual
92
+	 *
93
+	 * @param Tree $tree
94
+	 * @param UserInterface $user
95
+	 * @param Individual $indi
96
+	 * @return Collection<int, int>
97
+	 */
98
+	public function sosaNumbers(Tree $tree, UserInterface $user, Individual $indi): Collection
99
+	{
100
+		return Registry::cache()->array()->remember(
101
+			'sosanumbers-' . $indi->xref() . '@' . $tree->id() . '-' . $user->id(),
102
+			function () use ($tree, $user, $indi): Collection {
103
+				return DB::table('maj_sosa')
104
+					->select(['majs_sosa', 'majs_gen'])
105
+					->where('majs_gedcom_id', '=', $tree->id())
106
+					->where('majs_user_id', '=', $user->id())
107
+					->where('majs_i_id', '=', $indi->xref())
108
+					->orderBy('majs_sosa')
109
+					->get()->pluck('majs_gen', 'majs_sosa');
110
+			}
111
+		);
112
+	}
113 113
 
114
-    /**
115
-     * Return a list of the Sosa ancestors across all generation
116
-     *
117
-     * @param Tree $tree
118
-     * @param UserInterface $user
119
-     * @return Collection<\stdClass>
120
-     */
121
-    public function listAncestors(Tree $tree, UserInterface $user): Collection
122
-    {
123
-        return DB::table('maj_sosa')
124
-            ->select(['majs_sosa', 'majs_i_id'])
125
-            ->where('majs_gedcom_id', '=', $tree->id())
126
-            ->where('majs_user_id', '=', $user->id())
127
-            ->orderBy('majs_sosa')
128
-            ->get();
129
-    }
114
+	/**
115
+	 * Return a list of the Sosa ancestors across all generation
116
+	 *
117
+	 * @param Tree $tree
118
+	 * @param UserInterface $user
119
+	 * @return Collection<\stdClass>
120
+	 */
121
+	public function listAncestors(Tree $tree, UserInterface $user): Collection
122
+	{
123
+		return DB::table('maj_sosa')
124
+			->select(['majs_sosa', 'majs_i_id'])
125
+			->where('majs_gedcom_id', '=', $tree->id())
126
+			->where('majs_user_id', '=', $user->id())
127
+			->orderBy('majs_sosa')
128
+			->get();
129
+	}
130 130
 
131
-    /**
132
-     * Return a list of the Sosa ancestors at a given generation
133
-     *
134
-     * @param Tree $tree
135
-     * @param UserInterface $user
136
-     * @param int $gen
137
-     * @return Collection<\stdClass>
138
-     */
139
-    public function listAncestorsAtGeneration(Tree $tree, UserInterface $user, int $gen): Collection
140
-    {
141
-        return DB::table('maj_sosa')
142
-            ->select(['majs_sosa', 'majs_i_id'])
143
-            ->where('majs_gedcom_id', '=', $tree->id())
144
-            ->where('majs_user_id', '=', $user->id())
145
-            ->where('majs_gen', '=', $gen)
146
-            ->orderBy('majs_sosa')
147
-            ->get();
148
-    }
131
+	/**
132
+	 * Return a list of the Sosa ancestors at a given generation
133
+	 *
134
+	 * @param Tree $tree
135
+	 * @param UserInterface $user
136
+	 * @param int $gen
137
+	 * @return Collection<\stdClass>
138
+	 */
139
+	public function listAncestorsAtGeneration(Tree $tree, UserInterface $user, int $gen): Collection
140
+	{
141
+		return DB::table('maj_sosa')
142
+			->select(['majs_sosa', 'majs_i_id'])
143
+			->where('majs_gedcom_id', '=', $tree->id())
144
+			->where('majs_user_id', '=', $user->id())
145
+			->where('majs_gen', '=', $gen)
146
+			->orderBy('majs_sosa')
147
+			->get();
148
+	}
149 149
 
150
-    /**
151
-     * Return a list of the Sosa families at a given generation
152
-     *
153
-     * @param Tree $tree
154
-     * @param UserInterface $user
155
-     * @param int $gen
156
-     * @return Collection<\stdClass>
157
-     */
158
-    public function listAncestorFamiliesAtGeneration(Tree $tree, UserInterface $user, int $gen): Collection
159
-    {
160
-        $table_prefix = DB::connection()->getTablePrefix();
161
-        return DB::table('families')
162
-            ->join('maj_sosa AS sosa_husb', function (JoinClause $join) use ($tree, $user): void {
163
-                // Link to family husband
164
-                $join->on('families.f_file', '=', 'sosa_husb.majs_gedcom_id')
165
-                    ->on('families.f_husb', '=', 'sosa_husb.majs_i_id')
166
-                    ->where('sosa_husb.majs_gedcom_id', '=', $tree->id())
167
-                    ->where('sosa_husb.majs_user_id', '=', $user->id());
168
-            })
169
-            ->join('maj_sosa AS sosa_wife', function (JoinClause $join) use ($tree, $user): void {
170
-                // Link to family husband
171
-                $join->on('families.f_file', '=', 'sosa_wife.majs_gedcom_id')
172
-                ->on('families.f_wife', '=', 'sosa_wife.majs_i_id')
173
-                ->where('sosa_wife.majs_gedcom_id', '=', $tree->id())
174
-                ->where('sosa_wife.majs_user_id', '=', $user->id());
175
-            })
176
-            ->select(['sosa_husb.majs_sosa', 'families.f_id'])
177
-            ->where('sosa_husb.majs_gen', '=', $gen)
178
-            ->whereRaw($table_prefix . 'sosa_husb.majs_sosa + 1 = ' . $table_prefix . 'sosa_wife.majs_sosa')
179
-            ->orderBy('sosa_husb.majs_sosa')
180
-            ->get();
181
-    }
150
+	/**
151
+	 * Return a list of the Sosa families at a given generation
152
+	 *
153
+	 * @param Tree $tree
154
+	 * @param UserInterface $user
155
+	 * @param int $gen
156
+	 * @return Collection<\stdClass>
157
+	 */
158
+	public function listAncestorFamiliesAtGeneration(Tree $tree, UserInterface $user, int $gen): Collection
159
+	{
160
+		$table_prefix = DB::connection()->getTablePrefix();
161
+		return DB::table('families')
162
+			->join('maj_sosa AS sosa_husb', function (JoinClause $join) use ($tree, $user): void {
163
+				// Link to family husband
164
+				$join->on('families.f_file', '=', 'sosa_husb.majs_gedcom_id')
165
+					->on('families.f_husb', '=', 'sosa_husb.majs_i_id')
166
+					->where('sosa_husb.majs_gedcom_id', '=', $tree->id())
167
+					->where('sosa_husb.majs_user_id', '=', $user->id());
168
+			})
169
+			->join('maj_sosa AS sosa_wife', function (JoinClause $join) use ($tree, $user): void {
170
+				// Link to family husband
171
+				$join->on('families.f_file', '=', 'sosa_wife.majs_gedcom_id')
172
+				->on('families.f_wife', '=', 'sosa_wife.majs_i_id')
173
+				->where('sosa_wife.majs_gedcom_id', '=', $tree->id())
174
+				->where('sosa_wife.majs_user_id', '=', $user->id());
175
+			})
176
+			->select(['sosa_husb.majs_sosa', 'families.f_id'])
177
+			->where('sosa_husb.majs_gen', '=', $gen)
178
+			->whereRaw($table_prefix . 'sosa_husb.majs_sosa + 1 = ' . $table_prefix . 'sosa_wife.majs_sosa')
179
+			->orderBy('sosa_husb.majs_sosa')
180
+			->get();
181
+	}
182 182
 
183
-    /**
184
-     * Return a list of Sosa ancestors missing at a given generation.
185
-     * It includes the reference of either parent if it is known.
186
-     *
187
-     * @param Tree $tree
188
-     * @param UserInterface $user
189
-     * @param int $gen
190
-     * @return Collection<\stdClass>
191
-     */
192
-    public function listMissingAncestorsAtGeneration(Tree $tree, UserInterface $user, int $gen): Collection
193
-    {
194
-        if ($gen == 1) {
195
-            return collect();
196
-        }
183
+	/**
184
+	 * Return a list of Sosa ancestors missing at a given generation.
185
+	 * It includes the reference of either parent if it is known.
186
+	 *
187
+	 * @param Tree $tree
188
+	 * @param UserInterface $user
189
+	 * @param int $gen
190
+	 * @return Collection<\stdClass>
191
+	 */
192
+	public function listMissingAncestorsAtGeneration(Tree $tree, UserInterface $user, int $gen): Collection
193
+	{
194
+		if ($gen == 1) {
195
+			return collect();
196
+		}
197 197
 
198
-        $table_prefix = DB::connection()->getTablePrefix();
199
-        return DB::table('maj_sosa AS sosa')
200
-            ->select(['sosa.majs_i_id', 'sosa_fat.majs_i_id AS majs_fat_id', 'sosa_mot.majs_i_id AS majs_mot_id'])
201
-            ->selectRaw('MIN(' . $table_prefix . 'sosa.majs_sosa) AS majs_sosa')
202
-            ->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($tree, $user, $table_prefix): void {
203
-                // Link to sosa's father
204
-                $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
205
-                    ->where('sosa_fat.majs_gedcom_id', '=', $tree->id())
206
-                    ->where('sosa_fat.majs_user_id', '=', $user->id());
207
-            })
208
-            ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($tree, $user, $table_prefix): void {
209
-                // Link to sosa's mother
210
-                $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
211
-                    ->where('sosa_mot.majs_gedcom_id', '=', $tree->id())
212
-                    ->where('sosa_mot.majs_user_id', '=', $user->id());
213
-            })
214
-            ->where('sosa.majs_gedcom_id', '=', $tree->id())
215
-            ->where('sosa.majs_user_id', '=', $user->id())
216
-            ->where('sosa.majs_gen', '=', $gen - 1)
217
-            ->where(function (Builder $query): void {
218
-                $query->whereNull('sosa_fat.majs_i_id')
219
-                    ->orWhereNull('sosa_mot.majs_i_id');
220
-            })
221
-            ->groupBy('sosa.majs_i_id', 'sosa_fat.majs_i_id', 'sosa_mot.majs_i_id')
222
-            ->orderByRaw('MIN(' . $table_prefix . 'sosa.majs_sosa)')
223
-            ->get();
224
-    }
198
+		$table_prefix = DB::connection()->getTablePrefix();
199
+		return DB::table('maj_sosa AS sosa')
200
+			->select(['sosa.majs_i_id', 'sosa_fat.majs_i_id AS majs_fat_id', 'sosa_mot.majs_i_id AS majs_mot_id'])
201
+			->selectRaw('MIN(' . $table_prefix . 'sosa.majs_sosa) AS majs_sosa')
202
+			->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($tree, $user, $table_prefix): void {
203
+				// Link to sosa's father
204
+				$join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
205
+					->where('sosa_fat.majs_gedcom_id', '=', $tree->id())
206
+					->where('sosa_fat.majs_user_id', '=', $user->id());
207
+			})
208
+			->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($tree, $user, $table_prefix): void {
209
+				// Link to sosa's mother
210
+				$join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
211
+					->where('sosa_mot.majs_gedcom_id', '=', $tree->id())
212
+					->where('sosa_mot.majs_user_id', '=', $user->id());
213
+			})
214
+			->where('sosa.majs_gedcom_id', '=', $tree->id())
215
+			->where('sosa.majs_user_id', '=', $user->id())
216
+			->where('sosa.majs_gen', '=', $gen - 1)
217
+			->where(function (Builder $query): void {
218
+				$query->whereNull('sosa_fat.majs_i_id')
219
+					->orWhereNull('sosa_mot.majs_i_id');
220
+			})
221
+			->groupBy('sosa.majs_i_id', 'sosa_fat.majs_i_id', 'sosa_mot.majs_i_id')
222
+			->orderByRaw('MIN(' . $table_prefix . 'sosa.majs_sosa)')
223
+			->get();
224
+	}
225 225
 
226
-    /**
227
-     * Remove all Sosa entries related to the gedcom file and user
228
-     *
229
-     * @param Tree $tree
230
-     * @param UserInterface $user
231
-     */
232
-    public function deleteAll(Tree $tree, UserInterface $user): void
233
-    {
234
-        DB::table('maj_sosa')
235
-            ->where('majs_gedcom_id', '=', $tree->id())
236
-            ->where('majs_user_id', '=', $user->id())
237
-            ->delete();
238
-    }
226
+	/**
227
+	 * Remove all Sosa entries related to the gedcom file and user
228
+	 *
229
+	 * @param Tree $tree
230
+	 * @param UserInterface $user
231
+	 */
232
+	public function deleteAll(Tree $tree, UserInterface $user): void
233
+	{
234
+		DB::table('maj_sosa')
235
+			->where('majs_gedcom_id', '=', $tree->id())
236
+			->where('majs_user_id', '=', $user->id())
237
+			->delete();
238
+	}
239 239
 
240
-    /**
241
-     *
242
-     * @param Tree $tree
243
-     * @param UserInterface $user
244
-     * @param int $sosa
245
-     */
246
-    public function deleteAncestorsFrom(Tree $tree, UserInterface $user, int $sosa): void
247
-    {
248
-        DB::table('maj_sosa')
249
-            ->where('majs_gedcom_id', '=', $tree->id())
250
-            ->where('majs_user_id', '=', $user->id())
251
-            ->where('majs_sosa', '>=', $sosa)
252
-            ->whereRaw(
253
-                'FLOOR(majs_sosa / (POW(2, (majs_gen - ?)))) = ?',
254
-                [$this->generation($sosa), $sosa]
255
-            )
256
-            ->delete();
257
-    }
240
+	/**
241
+	 *
242
+	 * @param Tree $tree
243
+	 * @param UserInterface $user
244
+	 * @param int $sosa
245
+	 */
246
+	public function deleteAncestorsFrom(Tree $tree, UserInterface $user, int $sosa): void
247
+	{
248
+		DB::table('maj_sosa')
249
+			->where('majs_gedcom_id', '=', $tree->id())
250
+			->where('majs_user_id', '=', $user->id())
251
+			->where('majs_sosa', '>=', $sosa)
252
+			->whereRaw(
253
+				'FLOOR(majs_sosa / (POW(2, (majs_gen - ?)))) = ?',
254
+				[$this->generation($sosa), $sosa]
255
+			)
256
+			->delete();
257
+	}
258 258
 
259
-    /**
260
-     * Insert (or update if already existing) a list of Sosa individuals
261
-     *
262
-     * @param Tree $tree
263
-     * @param UserInterface $user
264
-     * @param array<array<string,mixed>> $sosa_records
265
-     */
266
-    public function insertOrUpdate(Tree $tree, UserInterface $user, array $sosa_records): void
267
-    {
268
-        $mass_update = DB::connection()->getDriverName() === 'mysql';
259
+	/**
260
+	 * Insert (or update if already existing) a list of Sosa individuals
261
+	 *
262
+	 * @param Tree $tree
263
+	 * @param UserInterface $user
264
+	 * @param array<array<string,mixed>> $sosa_records
265
+	 */
266
+	public function insertOrUpdate(Tree $tree, UserInterface $user, array $sosa_records): void
267
+	{
268
+		$mass_update = DB::connection()->getDriverName() === 'mysql';
269 269
 
270
-        $bindings_placeholders = $bindings_values = [];
271
-        $has_records = false;
272
-        foreach ($sosa_records as $i => $row) {
273
-            $gen = $this->generation($row['sosa']);
274
-            if ($gen <=  $this->maxSystemGenerations()) {
275
-                $has_records = true;
276
-                if ($mass_update) {
277
-                    $bindings_placeholders[] = '(:tree_id' . $i . ', :user_id' . $i . ', :sosa' . $i . ',' .
278
-                        ' :indi_id' . $i . ', :gen' . $i . ',' .
279
-                        ' :byear' . $i . ', :byearest' . $i . ', :dyear' . $i . ', :dyearest' . $i . ')';
280
-                    $bindings_values += [
281
-                        'tree_id' . $i => $tree->id(),
282
-                        'user_id' . $i => $user->id(),
283
-                        'sosa' . $i => $row['sosa'],
284
-                        'indi_id' . $i => $row['indi'],
285
-                        'gen' . $i => $gen,
286
-                        'byear' . $i => $row['birth_year'],
287
-                        'byearest' . $i => $row['birth_year_est'],
288
-                        'dyear' . $i => $row['death_year'],
289
-                        'dyearest' . $i => $row['death_year_est']
290
-                    ];
291
-                } else {
292
-                    DB::table('maj_sosa')->updateOrInsert(
293
-                        [ 'majs_gedcom_id' => $tree->id(), 'majs_user_id' => $user->id(), 'majs_sosa' => $row['sosa']],
294
-                        [
295
-                            'majs_i_id' => $row['indi'],
296
-                            'majs_gen' => $gen,
297
-                            'majs_birth_year' => $row['birth_year'],
298
-                            'majs_birth_year_est' => $row['birth_year_est'],
299
-                            'majs_death_year' => $row['death_year'],
300
-                            'majs_death_year_est' => $row['death_year_est']
301
-                        ]
302
-                    );
303
-                }
304
-            }
305
-        }
270
+		$bindings_placeholders = $bindings_values = [];
271
+		$has_records = false;
272
+		foreach ($sosa_records as $i => $row) {
273
+			$gen = $this->generation($row['sosa']);
274
+			if ($gen <=  $this->maxSystemGenerations()) {
275
+				$has_records = true;
276
+				if ($mass_update) {
277
+					$bindings_placeholders[] = '(:tree_id' . $i . ', :user_id' . $i . ', :sosa' . $i . ',' .
278
+						' :indi_id' . $i . ', :gen' . $i . ',' .
279
+						' :byear' . $i . ', :byearest' . $i . ', :dyear' . $i . ', :dyearest' . $i . ')';
280
+					$bindings_values += [
281
+						'tree_id' . $i => $tree->id(),
282
+						'user_id' . $i => $user->id(),
283
+						'sosa' . $i => $row['sosa'],
284
+						'indi_id' . $i => $row['indi'],
285
+						'gen' . $i => $gen,
286
+						'byear' . $i => $row['birth_year'],
287
+						'byearest' . $i => $row['birth_year_est'],
288
+						'dyear' . $i => $row['death_year'],
289
+						'dyearest' . $i => $row['death_year_est']
290
+					];
291
+				} else {
292
+					DB::table('maj_sosa')->updateOrInsert(
293
+						[ 'majs_gedcom_id' => $tree->id(), 'majs_user_id' => $user->id(), 'majs_sosa' => $row['sosa']],
294
+						[
295
+							'majs_i_id' => $row['indi'],
296
+							'majs_gen' => $gen,
297
+							'majs_birth_year' => $row['birth_year'],
298
+							'majs_birth_year_est' => $row['birth_year_est'],
299
+							'majs_death_year' => $row['death_year'],
300
+							'majs_death_year_est' => $row['death_year_est']
301
+						]
302
+					);
303
+				}
304
+			}
305
+		}
306 306
 
307
-        if ($has_records && $mass_update) {
308
-            DB::connection()->statement(
309
-                'INSERT INTO `' . DB::connection()->getTablePrefix() . 'maj_sosa`' .
310
-                ' (majs_gedcom_id, majs_user_id, majs_sosa,' .
311
-                '   majs_i_id, majs_gen, majs_birth_year, majs_birth_year_est, majs_death_year, majs_death_year_est)' .
312
-                ' VALUES ' . implode(',', $bindings_placeholders) .
313
-                ' ON DUPLICATE KEY UPDATE majs_i_id = VALUES(majs_i_id), majs_gen = VALUES(majs_gen),' .
314
-                '   majs_birth_year = VALUES(majs_birth_year), majs_birth_year_est = VALUES(majs_birth_year_est),' .
315
-                '   majs_death_year = VALUES(majs_death_year), majs_death_year_est = VALUES(majs_death_year_est)',
316
-                $bindings_values
317
-            );
318
-        }
319
-    }
307
+		if ($has_records && $mass_update) {
308
+			DB::connection()->statement(
309
+				'INSERT INTO `' . DB::connection()->getTablePrefix() . 'maj_sosa`' .
310
+				' (majs_gedcom_id, majs_user_id, majs_sosa,' .
311
+				'   majs_i_id, majs_gen, majs_birth_year, majs_birth_year_est, majs_death_year, majs_death_year_est)' .
312
+				' VALUES ' . implode(',', $bindings_placeholders) .
313
+				' ON DUPLICATE KEY UPDATE majs_i_id = VALUES(majs_i_id), majs_gen = VALUES(majs_gen),' .
314
+				'   majs_birth_year = VALUES(majs_birth_year), majs_birth_year_est = VALUES(majs_birth_year_est),' .
315
+				'   majs_death_year = VALUES(majs_death_year), majs_death_year_est = VALUES(majs_death_year_est)',
316
+				$bindings_values
317
+			);
318
+		}
319
+	}
320 320
 }
Please login to merge, or discard this patch.
app/Module/Hooks/Hooks/SosaMissingDatatablesExtenderCollector.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -25,45 +25,45 @@
 block discarded – undo
25 25
  * @extends AbstractHookCollector<SosaMissingDatatablesExtenderInterface>
26 26
  */
27 27
 class SosaMissingDatatablesExtenderCollector extends AbstractHookCollector implements
28
-    SosaMissingDatatablesExtenderInterface
28
+	SosaMissingDatatablesExtenderInterface
29 29
 {
30
-    /**
31
-     * {@inheritDoc}
32
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
-     */
34
-    public function title(): string
35
-    {
36
-        return I18N::translate('Columns extender for tables of missing ancestors');
37
-    }
30
+	/**
31
+	 * {@inheritDoc}
32
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
+	 */
34
+	public function title(): string
35
+	{
36
+		return I18N::translate('Columns extender for tables of missing ancestors');
37
+	}
38 38
 
39
-    /**
40
-     * {@inheritDoc}
41
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
-     */
43
-    public function description(): string
44
-    {
45
-        return I18N::translate('Add additional columns to tables of missing ancestors');
46
-    }
39
+	/**
40
+	 * {@inheritDoc}
41
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
+	 */
43
+	public function description(): string
44
+	{
45
+		return I18N::translate('Add additional columns to tables of missing ancestors');
46
+	}
47 47
 
48
-    /**
49
-     * {@inheritDoc}
50
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
-     */
52
-    public function hookInterface(): string
53
-    {
54
-        return SosaMissingDatatablesExtenderInterface::class;
55
-    }
48
+	/**
49
+	 * {@inheritDoc}
50
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
+	 */
52
+	public function hookInterface(): string
53
+	{
54
+		return SosaMissingDatatablesExtenderInterface::class;
55
+	}
56 56
 
57
-    /**
58
-     * {@inheritDoc}
59
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\SosaMissingDatatablesExtenderInterface::sosaMissingColumns()
60
-     */
61
-    public function sosaMissingColumns(iterable $records): array
62
-    {
63
-        $result = [];
64
-        foreach ($this->hooks() as $hook) {
65
-            $result += $hook->sosaMissingColumns($records);
66
-        }
67
-        return $result;
68
-    }
57
+	/**
58
+	 * {@inheritDoc}
59
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\SosaMissingDatatablesExtenderInterface::sosaMissingColumns()
60
+	 */
61
+	public function sosaMissingColumns(iterable $records): array
62
+	{
63
+		$result = [];
64
+		foreach ($this->hooks() as $hook) {
65
+			$result += $hook->sosaMissingColumns($records);
66
+		}
67
+		return $result;
68
+	}
69 69
 }
Please login to merge, or discard this patch.
app/Module/Hooks/Hooks/SosaFamilyDatatablesExtenderCollector.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -25,45 +25,45 @@
 block discarded – undo
25 25
  * @extends AbstractHookCollector<SosaFamilyDatatablesExtenderInterface>
26 26
  */
27 27
 class SosaFamilyDatatablesExtenderCollector extends AbstractHookCollector implements
28
-    SosaFamilyDatatablesExtenderInterface
28
+	SosaFamilyDatatablesExtenderInterface
29 29
 {
30
-    /**
31
-     * {@inheritDoc}
32
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
-     */
34
-    public function title(): string
35
-    {
36
-        return I18N::translate('Columns extender for tables of ancestors’ families');
37
-    }
30
+	/**
31
+	 * {@inheritDoc}
32
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
+	 */
34
+	public function title(): string
35
+	{
36
+		return I18N::translate('Columns extender for tables of ancestors’ families');
37
+	}
38 38
 
39
-    /**
40
-     * {@inheritDoc}
41
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
-     */
43
-    public function description(): string
44
-    {
45
-        return I18N::translate('Add additional columns to tables of ancestors’ families');
46
-    }
39
+	/**
40
+	 * {@inheritDoc}
41
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
+	 */
43
+	public function description(): string
44
+	{
45
+		return I18N::translate('Add additional columns to tables of ancestors’ families');
46
+	}
47 47
 
48
-    /**
49
-     * {@inheritDoc}
50
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
-     */
52
-    public function hookInterface(): string
53
-    {
54
-        return SosaFamilyDatatablesExtenderInterface::class;
55
-    }
48
+	/**
49
+	 * {@inheritDoc}
50
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
+	 */
52
+	public function hookInterface(): string
53
+	{
54
+		return SosaFamilyDatatablesExtenderInterface::class;
55
+	}
56 56
 
57
-    /**
58
-     * {@inheritDoc}
59
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\SosaFamilyDatatablesExtenderInterface::sosaFamilyColumns()
60
-     */
61
-    public function sosaFamilyColumns(iterable $records): array
62
-    {
63
-        $result = [];
64
-        foreach ($this->hooks() as $hook) {
65
-            $result += $hook->sosaFamilyColumns($records);
66
-        }
67
-        return $result;
68
-    }
57
+	/**
58
+	 * {@inheritDoc}
59
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\SosaFamilyDatatablesExtenderInterface::sosaFamilyColumns()
60
+	 */
61
+	public function sosaFamilyColumns(iterable $records): array
62
+	{
63
+		$result = [];
64
+		foreach ($this->hooks() as $hook) {
65
+			$result += $hook->sosaFamilyColumns($records);
66
+		}
67
+		return $result;
68
+	}
69 69
 }
Please login to merge, or discard this patch.
app/Module/Hooks/Hooks/SosaIndividualDatatablesExtenderCollector.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -25,45 +25,45 @@
 block discarded – undo
25 25
  * @extends AbstractHookCollector<SosaIndividualDatatablesExtenderInterface>
26 26
  */
27 27
 class SosaIndividualDatatablesExtenderCollector extends AbstractHookCollector implements
28
-    SosaIndividualDatatablesExtenderInterface
28
+	SosaIndividualDatatablesExtenderInterface
29 29
 {
30
-    /**
31
-     * {@inheritDoc}
32
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
-     */
34
-    public function title(): string
35
-    {
36
-        return I18N::translate('Columns extender for tables of ancestors');
37
-    }
30
+	/**
31
+	 * {@inheritDoc}
32
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
+	 */
34
+	public function title(): string
35
+	{
36
+		return I18N::translate('Columns extender for tables of ancestors');
37
+	}
38 38
 
39
-    /**
40
-     * {@inheritDoc}
41
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
-     */
43
-    public function description(): string
44
-    {
45
-        return I18N::translate('Add additional columns to tables of ancestors');
46
-    }
39
+	/**
40
+	 * {@inheritDoc}
41
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
+	 */
43
+	public function description(): string
44
+	{
45
+		return I18N::translate('Add additional columns to tables of ancestors');
46
+	}
47 47
 
48
-    /**
49
-     * {@inheritDoc}
50
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
-     */
52
-    public function hookInterface(): string
53
-    {
54
-        return SosaIndividualDatatablesExtenderInterface::class;
55
-    }
48
+	/**
49
+	 * {@inheritDoc}
50
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
+	 */
52
+	public function hookInterface(): string
53
+	{
54
+		return SosaIndividualDatatablesExtenderInterface::class;
55
+	}
56 56
 
57
-    /**
58
-     * {@inheritDoc}
59
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\SosaIndividualDatatablesExtenderInterface::sosaIndividualColumns()
60
-     */
61
-    public function sosaIndividualColumns(iterable $records): array
62
-    {
63
-        $result = [];
64
-        foreach ($this->hooks() as $hook) {
65
-            $result += $hook->sosaIndividualColumns($records);
66
-        }
67
-        return $result;
68
-    }
57
+	/**
58
+	 * {@inheritDoc}
59
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\SosaIndividualDatatablesExtenderInterface::sosaIndividualColumns()
60
+	 */
61
+	public function sosaIndividualColumns(iterable $records): array
62
+	{
63
+		$result = [];
64
+		foreach ($this->hooks() as $hook) {
65
+			$result += $hook->sosaIndividualColumns($records);
66
+		}
67
+		return $result;
68
+	}
69 69
 }
Please login to merge, or discard this patch.
app/Module/Hooks/Hooks/FactSourceTextExtenderCollector.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -27,56 +27,56 @@
 block discarded – undo
27 27
  */
28 28
 class FactSourceTextExtenderCollector extends AbstractHookCollector implements FactSourceTextExtenderInterface
29 29
 {
30
-    /**
31
-     * {@inheritDoc}
32
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
-     */
34
-    public function title(): string
35
-    {
36
-        return I18N::translate('Text extender for source citations’ title');
37
-    }
30
+	/**
31
+	 * {@inheritDoc}
32
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
+	 */
34
+	public function title(): string
35
+	{
36
+		return I18N::translate('Text extender for source citations’ title');
37
+	}
38 38
 
39
-    /**
40
-     * {@inheritDoc}
41
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
-     */
43
-    public function description(): string
44
-    {
45
-        return I18N::translate('Extends the title of source citations with additional text or icons.');
46
-    }
39
+	/**
40
+	 * {@inheritDoc}
41
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
+	 */
43
+	public function description(): string
44
+	{
45
+		return I18N::translate('Extends the title of source citations with additional text or icons.');
46
+	}
47 47
 
48
-    /**
49
-     * {@inheritDoc}
50
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
-     */
52
-    public function hookInterface(): string
53
-    {
54
-        return FactSourceTextExtenderInterface::class;
55
-    }
48
+	/**
49
+	 * {@inheritDoc}
50
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
+	 */
52
+	public function hookInterface(): string
53
+	{
54
+		return FactSourceTextExtenderInterface::class;
55
+	}
56 56
 
57
-    /**
58
-     * {@inheritDoc}
59
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourcePrepend()
60
-     */
61
-    public function factSourcePrepend(Tree $tree, $fact): string
62
-    {
63
-        return $this->hooks()
64
-            ->map(
65
-                fn(FactSourceTextExtenderInterface $hook) =>
66
-                    $hook->factSourcePrepend($tree, $fact)
67
-            )->implode('');
68
-    }
57
+	/**
58
+	 * {@inheritDoc}
59
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourcePrepend()
60
+	 */
61
+	public function factSourcePrepend(Tree $tree, $fact): string
62
+	{
63
+		return $this->hooks()
64
+			->map(
65
+				fn(FactSourceTextExtenderInterface $hook) =>
66
+					$hook->factSourcePrepend($tree, $fact)
67
+			)->implode('');
68
+	}
69 69
 
70
-    /**
71
-     * {@inheritDoc}
72
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourceAppend()
73
-     */
74
-    public function factSourceAppend(Tree $tree, $fact): string
75
-    {
76
-        return $this->hooks()
77
-            ->map(
78
-                fn(FactSourceTextExtenderInterface $hook) =>
79
-                    $hook->factSourcePrepend($tree, $fact)
80
-            )->implode('');
81
-    }
70
+	/**
71
+	 * {@inheritDoc}
72
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourceAppend()
73
+	 */
74
+	public function factSourceAppend(Tree $tree, $fact): string
75
+	{
76
+		return $this->hooks()
77
+			->map(
78
+				fn(FactSourceTextExtenderInterface $hook) =>
79
+					$hook->factSourcePrepend($tree, $fact)
80
+			)->implode('');
81
+	}
82 82
 }
Please login to merge, or discard this patch.
app/Module/Hooks/Hooks/FamilyDatatablesExtenderCollector.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -25,45 +25,45 @@
 block discarded – undo
25 25
  * @extends AbstractHookCollector<FamilyDatatablesExtenderInterface>
26 26
  */
27 27
 class FamilyDatatablesExtenderCollector extends AbstractHookCollector implements
28
-    FamilyDatatablesExtenderInterface
28
+	FamilyDatatablesExtenderInterface
29 29
 {
30
-    /**
31
-     * {@inheritDoc}
32
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
-     */
34
-    public function title(): string
35
-    {
36
-        return I18N::translate('Columns extender for tables of families');
37
-    }
30
+	/**
31
+	 * {@inheritDoc}
32
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
+	 */
34
+	public function title(): string
35
+	{
36
+		return I18N::translate('Columns extender for tables of families');
37
+	}
38 38
 
39
-    /**
40
-     * {@inheritDoc}
41
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
-     */
43
-    public function description(): string
44
-    {
45
-        return I18N::translate('Add additional columns to tables of families');
46
-    }
39
+	/**
40
+	 * {@inheritDoc}
41
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
+	 */
43
+	public function description(): string
44
+	{
45
+		return I18N::translate('Add additional columns to tables of families');
46
+	}
47 47
 
48
-    /**
49
-     * {@inheritDoc}
50
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
-     */
52
-    public function hookInterface(): string
53
-    {
54
-        return FamilyDatatablesExtenderInterface::class;
55
-    }
48
+	/**
49
+	 * {@inheritDoc}
50
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
+	 */
52
+	public function hookInterface(): string
53
+	{
54
+		return FamilyDatatablesExtenderInterface::class;
55
+	}
56 56
 
57
-    /**
58
-     * {@inheritDoc}
59
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\FamilyDatatablesExtenderInterface::familyColumns()
60
-     */
61
-    public function familyColumns(iterable $records): array
62
-    {
63
-        $result = [];
64
-        foreach ($this->hooks() as $hook) {
65
-            $result += $hook->familyColumns($records);
66
-        }
67
-        return $result;
68
-    }
57
+	/**
58
+	 * {@inheritDoc}
59
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\FamilyDatatablesExtenderInterface::familyColumns()
60
+	 */
61
+	public function familyColumns(iterable $records): array
62
+	{
63
+		$result = [];
64
+		foreach ($this->hooks() as $hook) {
65
+			$result += $hook->familyColumns($records);
66
+		}
67
+		return $result;
68
+	}
69 69
 }
Please login to merge, or discard this patch.
app/Module/Hooks/Hooks/IndividualDatatablesExtenderCollector.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -25,45 +25,45 @@
 block discarded – undo
25 25
  * @extends AbstractHookCollector<IndividualDatatablesExtenderInterface>
26 26
  */
27 27
 class IndividualDatatablesExtenderCollector extends AbstractHookCollector implements
28
-    IndividualDatatablesExtenderInterface
28
+	IndividualDatatablesExtenderInterface
29 29
 {
30
-    /**
31
-     * {@inheritDoc}
32
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
-     */
34
-    public function title(): string
35
-    {
36
-        return I18N::translate('Columns extender for tables of individuals');
37
-    }
30
+	/**
31
+	 * {@inheritDoc}
32
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title()
33
+	 */
34
+	public function title(): string
35
+	{
36
+		return I18N::translate('Columns extender for tables of individuals');
37
+	}
38 38
 
39
-    /**
40
-     * {@inheritDoc}
41
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
-     */
43
-    public function description(): string
44
-    {
45
-        return I18N::translate('Add additional columns to tables of individuals');
46
-    }
39
+	/**
40
+	 * {@inheritDoc}
41
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description()
42
+	 */
43
+	public function description(): string
44
+	{
45
+		return I18N::translate('Add additional columns to tables of individuals');
46
+	}
47 47
 
48
-    /**
49
-     * {@inheritDoc}
50
-     * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
-     */
52
-    public function hookInterface(): string
53
-    {
54
-        return IndividualDatatablesExtenderInterface::class;
55
-    }
48
+	/**
49
+	 * {@inheritDoc}
50
+	 * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface()
51
+	 */
52
+	public function hookInterface(): string
53
+	{
54
+		return IndividualDatatablesExtenderInterface::class;
55
+	}
56 56
 
57
-    /**
58
-     * {@inheritDoc}
59
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\IndividualDatatablesExtenderInterface::individualColumns()
60
-     */
61
-    public function individualColumns(iterable $records): array
62
-    {
63
-        $result = [];
64
-        foreach ($this->hooks() as $hook) {
65
-            $result += $hook->individualColumns($records);
66
-        }
67
-        return $result;
68
-    }
57
+	/**
58
+	 * {@inheritDoc}
59
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\IndividualDatatablesExtenderInterface::individualColumns()
60
+	 */
61
+	public function individualColumns(iterable $records): array
62
+	{
63
+		$result = [];
64
+		foreach ($this->hooks() as $hook) {
65
+			$result += $hook->individualColumns($records);
66
+		}
67
+		return $result;
68
+	}
69 69
 }
Please login to merge, or discard this patch.
app/Module/Hooks/HooksModule.php 1 patch
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -42,106 +42,106 @@
 block discarded – undo
42 42
  * Provide entry points to extend core webtrees code.
43 43
  */
44 44
 class HooksModule extends AbstractModule implements
45
-    ModuleMyArtJaubInterface,
46
-    ModuleConfigInterface,
47
-    ModuleHookSubscriberInterface
45
+	ModuleMyArtJaubInterface,
46
+	ModuleConfigInterface,
47
+	ModuleHookSubscriberInterface
48 48
 {
49
-    use ModuleMyArtJaubTrait {
50
-        boot as traitBoot;
51
-    }
52
-    use ModuleConfigTrait;
53
-
54
-    // How to update the database schema for this module
55
-    private const SCHEMA_TARGET_VERSION   = 2;
56
-    private const SCHEMA_SETTING_NAME     = 'MAJ_HOOKS_SCHEMA_VERSION';
57
-    private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema';
58
-
59
-    /**
60
-     * {@inheritDoc}
61
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
62
-     */
63
-    public function title(): string
64
-    {
65
-        return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks');
66
-    }
67
-
68
-    /**
69
-     * {@inheritDoc}
70
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
71
-     */
72
-    public function description(): string
73
-    {
74
-        return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.');
75
-    }
76
-
77
-    /**
78
-     * {@inheritDoc}
79
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
80
-     */
81
-    public function boot(): void
82
-    {
83
-        $this->traitBoot();
84
-        app()->bind(HookServiceInterface::class, HookService::class);
85
-        app(MigrationService::class)->updateSchema(
86
-            self::SCHEMA_MIGRATION_PREFIX,
87
-            self::SCHEMA_SETTING_NAME,
88
-            self::SCHEMA_TARGET_VERSION
89
-        );
90
-    }
91
-
92
-    /**
93
-     * {@inheritDoc}
94
-     * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
95
-     */
96
-    public function loadRoutes(Map $router): void
97
-    {
98
-        $router->attach('', '', static function (Map $router): void {
99
-
100
-            $router->attach('', '/module-maj/hooks', static function (Map $router): void {
101
-
102
-                $router->attach('', '/config/admin', static function (Map $router): void {
103
-
104
-                    $router->get(AdminConfigPage::class, '', AdminConfigPage::class);
105
-                    $router->get(ModulesHooksPage::class, '/{hook_name}', ModulesHooksPage::class);
106
-                    $router->post(ModulesHooksAction::class, '/{hook_name}', ModulesHooksAction::class);
107
-                });
108
-            });
109
-        });
110
-    }
111
-
112
-    /**
113
-     * {@inheritDoc}
114
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
115
-     */
116
-    public function customModuleVersion(): string
117
-    {
118
-        return '2.1.1-v.1';
119
-    }
120
-
121
-    /**
122
-     * {@inheritDoc}
123
-     * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
124
-     */
125
-    public function getConfigLink(): string
126
-    {
127
-        return route(AdminConfigPage::class);
128
-    }
129
-
130
-    /**
131
-     * {@inheritDoc}
132
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks()
133
-     */
134
-    public function listSubscribedHooks(): array
135
-    {
136
-        return [
137
-            app()->makeWith(FactSourceTextExtenderCollector::class, ['module' => $this]),
138
-            app()->makeWith(FamilyDatatablesExtenderCollector::class, ['module' => $this]),
139
-            app()->makeWith(IndividualDatatablesExtenderCollector::class, ['module' => $this]),
140
-            app()->makeWith(NameAccordionExtenderCollector::class, ['module' => $this]),
141
-            app()->makeWith(RecordNameTextExtenderCollector::class, ['module' => $this]),
142
-            app()->makeWith(SosaFamilyDatatablesExtenderCollector::class, ['module' => $this]),
143
-            app()->makeWith(SosaIndividualDatatablesExtenderCollector::class, ['module' => $this]),
144
-            app()->makeWith(SosaMissingDatatablesExtenderCollector::class, ['module' => $this])
145
-        ];
146
-    }
49
+	use ModuleMyArtJaubTrait {
50
+		boot as traitBoot;
51
+	}
52
+	use ModuleConfigTrait;
53
+
54
+	// How to update the database schema for this module
55
+	private const SCHEMA_TARGET_VERSION   = 2;
56
+	private const SCHEMA_SETTING_NAME     = 'MAJ_HOOKS_SCHEMA_VERSION';
57
+	private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema';
58
+
59
+	/**
60
+	 * {@inheritDoc}
61
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
62
+	 */
63
+	public function title(): string
64
+	{
65
+		return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks');
66
+	}
67
+
68
+	/**
69
+	 * {@inheritDoc}
70
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
71
+	 */
72
+	public function description(): string
73
+	{
74
+		return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.');
75
+	}
76
+
77
+	/**
78
+	 * {@inheritDoc}
79
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
80
+	 */
81
+	public function boot(): void
82
+	{
83
+		$this->traitBoot();
84
+		app()->bind(HookServiceInterface::class, HookService::class);
85
+		app(MigrationService::class)->updateSchema(
86
+			self::SCHEMA_MIGRATION_PREFIX,
87
+			self::SCHEMA_SETTING_NAME,
88
+			self::SCHEMA_TARGET_VERSION
89
+		);
90
+	}
91
+
92
+	/**
93
+	 * {@inheritDoc}
94
+	 * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
95
+	 */
96
+	public function loadRoutes(Map $router): void
97
+	{
98
+		$router->attach('', '', static function (Map $router): void {
99
+
100
+			$router->attach('', '/module-maj/hooks', static function (Map $router): void {
101
+
102
+				$router->attach('', '/config/admin', static function (Map $router): void {
103
+
104
+					$router->get(AdminConfigPage::class, '', AdminConfigPage::class);
105
+					$router->get(ModulesHooksPage::class, '/{hook_name}', ModulesHooksPage::class);
106
+					$router->post(ModulesHooksAction::class, '/{hook_name}', ModulesHooksAction::class);
107
+				});
108
+			});
109
+		});
110
+	}
111
+
112
+	/**
113
+	 * {@inheritDoc}
114
+	 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
115
+	 */
116
+	public function customModuleVersion(): string
117
+	{
118
+		return '2.1.1-v.1';
119
+	}
120
+
121
+	/**
122
+	 * {@inheritDoc}
123
+	 * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
124
+	 */
125
+	public function getConfigLink(): string
126
+	{
127
+		return route(AdminConfigPage::class);
128
+	}
129
+
130
+	/**
131
+	 * {@inheritDoc}
132
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks()
133
+	 */
134
+	public function listSubscribedHooks(): array
135
+	{
136
+		return [
137
+			app()->makeWith(FactSourceTextExtenderCollector::class, ['module' => $this]),
138
+			app()->makeWith(FamilyDatatablesExtenderCollector::class, ['module' => $this]),
139
+			app()->makeWith(IndividualDatatablesExtenderCollector::class, ['module' => $this]),
140
+			app()->makeWith(NameAccordionExtenderCollector::class, ['module' => $this]),
141
+			app()->makeWith(RecordNameTextExtenderCollector::class, ['module' => $this]),
142
+			app()->makeWith(SosaFamilyDatatablesExtenderCollector::class, ['module' => $this]),
143
+			app()->makeWith(SosaIndividualDatatablesExtenderCollector::class, ['module' => $this]),
144
+			app()->makeWith(SosaMissingDatatablesExtenderCollector::class, ['module' => $this])
145
+		];
146
+	}
147 147
 }
Please login to merge, or discard this patch.
app/Module/Hooks/Schema/Migration0.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@
 block discarded – undo
21 21
  */
22 22
 class Migration0 implements MigrationInterface
23 23
 {
24
-    /**
25
-     * {@inheritDoc}
26
-     * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
27
-     */
28
-    public function upgrade(): void
29
-    {
24
+	/**
25
+	 * {@inheritDoc}
26
+	 * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
27
+	 */
28
+	public function upgrade(): void
29
+	{
30 30
 
31
-        // This migration has been superseded by migration 1.
32
-    }
31
+		// This migration has been superseded by migration 1.
32
+	}
33 33
 }
Please login to merge, or discard this patch.