Passed
Push — main ( 00c5b4...fe37d7 )
by Jonathan
03:49
created
app/Module/Certificates/Http/RequestHandlers/AdminConfigAction.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -30,71 +30,71 @@
 block discarded – undo
30 30
  */
31 31
 class AdminConfigAction implements RequestHandlerInterface
32 32
 {
33
-    private ?CertificatesModule $module;
33
+	private ?CertificatesModule $module;
34 34
 
35
-    /**
36
-     * Constructor for Admin Config Action request handler
37
-     *
38
-     * @param ModuleService $module_service
39
-     */
40
-    public function __construct(ModuleService $module_service)
41
-    {
42
-        $this->module = $module_service->findByInterface(CertificatesModule::class)->first();
43
-    }
35
+	/**
36
+	 * Constructor for Admin Config Action request handler
37
+	 *
38
+	 * @param ModuleService $module_service
39
+	 */
40
+	public function __construct(ModuleService $module_service)
41
+	{
42
+		$this->module = $module_service->findByInterface(CertificatesModule::class)->first();
43
+	}
44 44
 
45
-    /**
46
-     * {@inheritDoc}
47
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
48
-     */
49
-    public function handle(ServerRequestInterface $request): ResponseInterface
50
-    {
51
-        $tree = Validator::attributes($request)->tree();
45
+	/**
46
+	 * {@inheritDoc}
47
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
48
+	 */
49
+	public function handle(ServerRequestInterface $request): ResponseInterface
50
+	{
51
+		$tree = Validator::attributes($request)->tree();
52 52
 
53
-        if ($this->module === null) {
54
-            FlashMessages::addMessage(
55
-                I18N::translate('The attached module could not be found.'),
56
-                'danger'
57
-            );
58
-            return Registry::responseFactory()->redirect(AdminConfigPage::class, ['tree' => $tree->name()]);
59
-        }
53
+		if ($this->module === null) {
54
+			FlashMessages::addMessage(
55
+				I18N::translate('The attached module could not be found.'),
56
+				'danger'
57
+			);
58
+			return Registry::responseFactory()->redirect(AdminConfigPage::class, ['tree' => $tree->name()]);
59
+		}
60 60
 
61
-        $tree->setPreference(
62
-            'MAJ_CERTIF_SHOW_CERT',
63
-            (string) Validator::parsedBody($request)->integer('MAJ_CERTIF_SHOW_CERT', Auth::PRIV_HIDE)
64
-        );
65
-        $tree->setPreference(
66
-            'MAJ_CERTIF_SHOW_NO_WATERMARK',
67
-            (string) Validator::parsedBody($request)->integer('MAJ_CERTIF_SHOW_NO_WATERMARK', Auth::PRIV_HIDE)
68
-        );
69
-        $tree->setPreference(
70
-            'MAJ_CERTIF_WM_DEFAULT',
71
-            Validator::parsedBody($request)->string('MAJ_CERTIF_WM_DEFAULT', '')
72
-        );
61
+		$tree->setPreference(
62
+			'MAJ_CERTIF_SHOW_CERT',
63
+			(string) Validator::parsedBody($request)->integer('MAJ_CERTIF_SHOW_CERT', Auth::PRIV_HIDE)
64
+		);
65
+		$tree->setPreference(
66
+			'MAJ_CERTIF_SHOW_NO_WATERMARK',
67
+			(string) Validator::parsedBody($request)->integer('MAJ_CERTIF_SHOW_NO_WATERMARK', Auth::PRIV_HIDE)
68
+		);
69
+		$tree->setPreference(
70
+			'MAJ_CERTIF_WM_DEFAULT',
71
+			Validator::parsedBody($request)->string('MAJ_CERTIF_WM_DEFAULT', '')
72
+		);
73 73
 
74
-        $tree->setPreference(
75
-            'MAJ_CERTIF_WM_FONT_MAXSIZE',
76
-            (string) (
77
-                Validator::parsedBody($request)->isBetween(0, PHP_INT_MAX)->integer('MAJ_CERTIF_WM_FONT_MAXSIZE', 18)
78
-            )
79
-        );
74
+		$tree->setPreference(
75
+			'MAJ_CERTIF_WM_FONT_MAXSIZE',
76
+			(string) (
77
+				Validator::parsedBody($request)->isBetween(0, PHP_INT_MAX)->integer('MAJ_CERTIF_WM_FONT_MAXSIZE', 18)
78
+			)
79
+		);
80 80
 
81
-        // Only accept valid color for MAJ_WM_FONT_COLOR
82
-        $watermark_color = Validator::parsedBody($request)->string('MAJ_CERTIF_WM_FONT_COLOR', '');
83
-        if (preg_match('/#([a-fA-F0-9]{3}){1,2}/', $watermark_color) === 1) {
84
-            $tree->setPreference('MAJ_CERTIF_WM_FONT_COLOR', $watermark_color);
85
-        }
81
+		// Only accept valid color for MAJ_WM_FONT_COLOR
82
+		$watermark_color = Validator::parsedBody($request)->string('MAJ_CERTIF_WM_FONT_COLOR', '');
83
+		if (preg_match('/#([a-fA-F0-9]{3}){1,2}/', $watermark_color) === 1) {
84
+			$tree->setPreference('MAJ_CERTIF_WM_FONT_COLOR', $watermark_color);
85
+		}
86 86
 
87
-        // Only accept valid folders for MAJ_CERT_ROOTDIR
88
-        $cert_root_dir = Validator::parsedBody($request)->string('MAJ_CERTIF_ROOTDIR', '');
89
-        $cert_root_dir = preg_replace('/[:\/\\\\]+/', '/', $cert_root_dir) ?? '';
90
-        $cert_root_dir = trim($cert_root_dir, '/') . '/';
91
-        $tree->setPreference('MAJ_CERTIF_ROOTDIR', $cert_root_dir);
87
+		// Only accept valid folders for MAJ_CERT_ROOTDIR
88
+		$cert_root_dir = Validator::parsedBody($request)->string('MAJ_CERTIF_ROOTDIR', '');
89
+		$cert_root_dir = preg_replace('/[:\/\\\\]+/', '/', $cert_root_dir) ?? '';
90
+		$cert_root_dir = trim($cert_root_dir, '/') . '/';
91
+		$tree->setPreference('MAJ_CERTIF_ROOTDIR', $cert_root_dir);
92 92
 
93
-        FlashMessages::addMessage(
94
-            I18N::translate('The preferences for the module “%s” have been updated.', $this->module->title()),
95
-            'success'
96
-        );
93
+		FlashMessages::addMessage(
94
+			I18N::translate('The preferences for the module “%s” have been updated.', $this->module->title()),
95
+			'success'
96
+		);
97 97
 
98
-        return Registry::responseFactory()->redirect(AdminConfigPage::class, ['tree' => $tree->name()]);
99
-    }
98
+		return Registry::responseFactory()->redirect(AdminConfigPage::class, ['tree' => $tree->name()]);
99
+	}
100 100
 }
Please login to merge, or discard this patch.
app/Module/Certificates/Http/RequestHandlers/CertificatePage.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -35,79 +35,79 @@
 block discarded – undo
35 35
  */
36 36
 class CertificatePage implements RequestHandlerInterface
37 37
 {
38
-    use ViewResponseTrait;
39
-
40
-    /**
41
-     * @var CertificatesModule|null $module
42
-     */
43
-    private $module;
44
-
45
-    /**
46
-     * @var CertificateFilesystemService $certif_filesystem
47
-     */
48
-    private $certif_filesystem;
49
-
50
-    /**
51
-     * @var CertificateDataService $certif_data_service
52
-     */
53
-    private $certif_data_service;
54
-
55
-    /**
56
-     * @var UrlObfuscatorService $url_obfuscator_service
57
-     */
58
-    private $url_obfuscator_service;
59
-
60
-
61
-    /**
62
-     * Constructor for CertificatePage Request Handler
63
-     *
64
-     * @param ModuleService $module_service
65
-     * @param CertificateFilesystemService $certif_filesystem
66
-     * @param CertificateDataService $certif_data_service
67
-     * @param UrlObfuscatorService $url_obfuscator_service
68
-     */
69
-    public function __construct(
70
-        ModuleService $module_service,
71
-        CertificateFilesystemService $certif_filesystem,
72
-        CertificateDataService $certif_data_service,
73
-        UrlObfuscatorService $url_obfuscator_service
74
-    ) {
75
-        $this->module = $module_service->findByInterface(CertificatesModule::class)->first();
76
-        $this->certif_filesystem = $certif_filesystem;
77
-        $this->certif_data_service = $certif_data_service;
78
-        $this->url_obfuscator_service = $url_obfuscator_service;
79
-    }
80
-
81
-    /**
82
-     * {@inheritDoc}
83
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
84
-     */
85
-    public function handle(ServerRequestInterface $request): ResponseInterface
86
-    {
87
-        if ($this->module === null) {
88
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
89
-        }
90
-
91
-        $tree = Validator::attributes($request)->tree();
92
-
93
-        $certif_path = Validator::attributes($request)->string('cid', '');
94
-        if ($certif_path !== '' && $this->url_obfuscator_service->tryDeobfuscate($certif_path)) {
95
-            $certificate = $this->certif_filesystem->certificate($tree, $certif_path);
96
-        }
97
-
98
-        if (!isset($certificate)) {
99
-            FlashMessages::addMessage('The requested certificate is not valid.');
100
-            return Registry::responseFactory()->redirect(TreePage::class, ['tree' => $tree->name()]);
101
-        }
102
-
103
-        return $this->viewResponse($this->module->name() . '::certificate-page', [
104
-            'title'                     =>  I18N::translate('Certificate - %s', $certificate->name()),
105
-            'tree'                      =>  $tree,
106
-            'module_name'               =>  $this->module->name(),
107
-            'certificate'               =>  $certificate,
108
-            'url_obfuscator_service'    =>  $this->url_obfuscator_service,
109
-            'linked_individuals'        =>  $this->certif_data_service->linkedIndividuals($certificate),
110
-            'linked_families'           =>  $this->certif_data_service->linkedFamilies($certificate)
111
-        ]);
112
-    }
38
+	use ViewResponseTrait;
39
+
40
+	/**
41
+	 * @var CertificatesModule|null $module
42
+	 */
43
+	private $module;
44
+
45
+	/**
46
+	 * @var CertificateFilesystemService $certif_filesystem
47
+	 */
48
+	private $certif_filesystem;
49
+
50
+	/**
51
+	 * @var CertificateDataService $certif_data_service
52
+	 */
53
+	private $certif_data_service;
54
+
55
+	/**
56
+	 * @var UrlObfuscatorService $url_obfuscator_service
57
+	 */
58
+	private $url_obfuscator_service;
59
+
60
+
61
+	/**
62
+	 * Constructor for CertificatePage Request Handler
63
+	 *
64
+	 * @param ModuleService $module_service
65
+	 * @param CertificateFilesystemService $certif_filesystem
66
+	 * @param CertificateDataService $certif_data_service
67
+	 * @param UrlObfuscatorService $url_obfuscator_service
68
+	 */
69
+	public function __construct(
70
+		ModuleService $module_service,
71
+		CertificateFilesystemService $certif_filesystem,
72
+		CertificateDataService $certif_data_service,
73
+		UrlObfuscatorService $url_obfuscator_service
74
+	) {
75
+		$this->module = $module_service->findByInterface(CertificatesModule::class)->first();
76
+		$this->certif_filesystem = $certif_filesystem;
77
+		$this->certif_data_service = $certif_data_service;
78
+		$this->url_obfuscator_service = $url_obfuscator_service;
79
+	}
80
+
81
+	/**
82
+	 * {@inheritDoc}
83
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
84
+	 */
85
+	public function handle(ServerRequestInterface $request): ResponseInterface
86
+	{
87
+		if ($this->module === null) {
88
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
89
+		}
90
+
91
+		$tree = Validator::attributes($request)->tree();
92
+
93
+		$certif_path = Validator::attributes($request)->string('cid', '');
94
+		if ($certif_path !== '' && $this->url_obfuscator_service->tryDeobfuscate($certif_path)) {
95
+			$certificate = $this->certif_filesystem->certificate($tree, $certif_path);
96
+		}
97
+
98
+		if (!isset($certificate)) {
99
+			FlashMessages::addMessage('The requested certificate is not valid.');
100
+			return Registry::responseFactory()->redirect(TreePage::class, ['tree' => $tree->name()]);
101
+		}
102
+
103
+		return $this->viewResponse($this->module->name() . '::certificate-page', [
104
+			'title'                     =>  I18N::translate('Certificate - %s', $certificate->name()),
105
+			'tree'                      =>  $tree,
106
+			'module_name'               =>  $this->module->name(),
107
+			'certificate'               =>  $certificate,
108
+			'url_obfuscator_service'    =>  $this->url_obfuscator_service,
109
+			'linked_individuals'        =>  $this->certif_data_service->linkedIndividuals($certificate),
110
+			'linked_families'           =>  $this->certif_data_service->linkedFamilies($certificate)
111
+		]);
112
+	}
113 113
 }
Please login to merge, or discard this patch.
app/Module/Certificates/Model/Watermark.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -19,112 +19,112 @@
 block discarded – undo
19 19
  */
20 20
 class Watermark
21 21
 {
22
-    /**
23
-     * Default font color for watermarks
24
-     * @var string DEFAULT_COLOR
25
-     * */
26
-    public const DEFAULT_COLOR = '#4D6DF3';
27
-
28
-    /**
29
-     * Default maximum font size for watermarks
30
-     * @var int DEFAULT_SIZE
31
-     * */
32
-    public const DEFAULT_SIZE = 18;
33
-
34
-    /**
35
-     * @var string $text
36
-     */
37
-    private $text;
38
-
39
-    /**
40
-     * @var string $color;
41
-     */
42
-    private $color;
43
-
44
-
45
-    /**
46
-     * @var int $size
47
-     */
48
-    private $size;
49
-
50
-    /**
51
-     * Constructor for Watermark data class
52
-     *
53
-     * @param string $text
54
-     * @param string $color
55
-     * @param int $size
56
-     */
57
-    public function __construct(string $text, string $color, int $size)
58
-    {
59
-        $this->text = $text;
60
-        $this->color = $color;
61
-        $this->size = $size;
62
-    }
63
-
64
-    /**
65
-     * Get the watermark text.
66
-     *
67
-     * @return string
68
-     */
69
-    public function text(): string
70
-    {
71
-        return $this->text;
72
-    }
73
-
74
-    /**
75
-     * Get the watermark font color.
76
-     *
77
-     * @return string
78
-     */
79
-    public function color(): string
80
-    {
81
-        return $this->color;
82
-    }
83
-
84
-    /**
85
-     * Get the watermark maximum font size.
86
-     * @return int
87
-     */
88
-    public function size(): int
89
-    {
90
-        return $this->size;
91
-    }
92
-
93
-    /**
94
-     * Return an estimate of the size in pixels of the watermark text length.
95
-     *
96
-     * @return int
97
-     */
98
-    public function textLengthEstimate(): int
99
-    {
100
-        return $this->stringLengthEstimate(mb_strlen($this->text), $this->size);
101
-    }
102
-
103
-    /**
104
-     * Decrease the font size if necessary, based on the image width.
105
-     *
106
-     * @param int $width
107
-     */
108
-    public function adjustSize(int $width): void
109
-    {
110
-        $len = mb_strlen($this->text);
111
-        while ($this->stringLengthEstimate($len, $this->size) > 0.9 * $width) {
112
-            $this->size--;
113
-            if ($this->size === 2) {
114
-                return;
115
-            }
116
-        }
117
-    }
118
-
119
-    /**
120
-     * Return an estimate of the size in pixels of a text in a specified font size.
121
-     *
122
-     * @param int $text_length
123
-     * @param int $font_size
124
-     * @return int
125
-     */
126
-    private function stringLengthEstimate(int $text_length, int $font_size): int
127
-    {
128
-        return $text_length * (int) ceil(($font_size + 2) * 0.5);
129
-    }
22
+	/**
23
+	 * Default font color for watermarks
24
+	 * @var string DEFAULT_COLOR
25
+	 * */
26
+	public const DEFAULT_COLOR = '#4D6DF3';
27
+
28
+	/**
29
+	 * Default maximum font size for watermarks
30
+	 * @var int DEFAULT_SIZE
31
+	 * */
32
+	public const DEFAULT_SIZE = 18;
33
+
34
+	/**
35
+	 * @var string $text
36
+	 */
37
+	private $text;
38
+
39
+	/**
40
+	 * @var string $color;
41
+	 */
42
+	private $color;
43
+
44
+
45
+	/**
46
+	 * @var int $size
47
+	 */
48
+	private $size;
49
+
50
+	/**
51
+	 * Constructor for Watermark data class
52
+	 *
53
+	 * @param string $text
54
+	 * @param string $color
55
+	 * @param int $size
56
+	 */
57
+	public function __construct(string $text, string $color, int $size)
58
+	{
59
+		$this->text = $text;
60
+		$this->color = $color;
61
+		$this->size = $size;
62
+	}
63
+
64
+	/**
65
+	 * Get the watermark text.
66
+	 *
67
+	 * @return string
68
+	 */
69
+	public function text(): string
70
+	{
71
+		return $this->text;
72
+	}
73
+
74
+	/**
75
+	 * Get the watermark font color.
76
+	 *
77
+	 * @return string
78
+	 */
79
+	public function color(): string
80
+	{
81
+		return $this->color;
82
+	}
83
+
84
+	/**
85
+	 * Get the watermark maximum font size.
86
+	 * @return int
87
+	 */
88
+	public function size(): int
89
+	{
90
+		return $this->size;
91
+	}
92
+
93
+	/**
94
+	 * Return an estimate of the size in pixels of the watermark text length.
95
+	 *
96
+	 * @return int
97
+	 */
98
+	public function textLengthEstimate(): int
99
+	{
100
+		return $this->stringLengthEstimate(mb_strlen($this->text), $this->size);
101
+	}
102
+
103
+	/**
104
+	 * Decrease the font size if necessary, based on the image width.
105
+	 *
106
+	 * @param int $width
107
+	 */
108
+	public function adjustSize(int $width): void
109
+	{
110
+		$len = mb_strlen($this->text);
111
+		while ($this->stringLengthEstimate($len, $this->size) > 0.9 * $width) {
112
+			$this->size--;
113
+			if ($this->size === 2) {
114
+				return;
115
+			}
116
+		}
117
+	}
118
+
119
+	/**
120
+	 * Return an estimate of the size in pixels of a text in a specified font size.
121
+	 *
122
+	 * @param int $text_length
123
+	 * @param int $font_size
124
+	 * @return int
125
+	 */
126
+	private function stringLengthEstimate(int $text_length, int $font_size): int
127
+	{
128
+		return $text_length * (int) ceil(($font_size + 2) * 0.5);
129
+	}
130 130
 }
Please login to merge, or discard this patch.
app/Module/Certificates/Hooks/SourceCertificateIconHook.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -30,87 +30,87 @@
 block discarded – undo
30 30
  */
31 31
 class SourceCertificateIconHook implements FactSourceTextExtenderInterface
32 32
 {
33
-    private CertificatesModule $module;
34
-    private UrlObfuscatorService $url_obfuscator_service;
33
+	private CertificatesModule $module;
34
+	private UrlObfuscatorService $url_obfuscator_service;
35 35
 
36
-    /**
37
-     * Constructor for SourceCertificateIconHook
38
-     *
39
-     * @param CertificatesModule $module
40
-     * @param UrlObfuscatorService $url_obfuscator_service
41
-     */
42
-    public function __construct(CertificatesModule $module, UrlObfuscatorService $url_obfuscator_service)
43
-    {
44
-        $this->module = $module;
45
-        $this->url_obfuscator_service = $url_obfuscator_service;
46
-    }
36
+	/**
37
+	 * Constructor for SourceCertificateIconHook
38
+	 *
39
+	 * @param CertificatesModule $module
40
+	 * @param UrlObfuscatorService $url_obfuscator_service
41
+	 */
42
+	public function __construct(CertificatesModule $module, UrlObfuscatorService $url_obfuscator_service)
43
+	{
44
+		$this->module = $module;
45
+		$this->url_obfuscator_service = $url_obfuscator_service;
46
+	}
47 47
 
48
-    /**
49
-     * {@inheritDoc}
50
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module()
51
-     */
52
-    public function module(): ModuleInterface
53
-    {
54
-        return $this->module;
55
-    }
48
+	/**
49
+	 * {@inheritDoc}
50
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module()
51
+	 */
52
+	public function module(): ModuleInterface
53
+	{
54
+		return $this->module;
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
-        $permission_level = $tree->getPreference('MAJ_CERTIF_SHOW_CERT');
64
-        if (is_numeric($permission_level) && Auth::accessLevel($tree) <= (int) $permission_level) {
65
-            $path = $this->extractPath($fact);
57
+	/**
58
+	 * {@inheritDoc}
59
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourcePrepend()
60
+	 */
61
+	public function factSourcePrepend(Tree $tree, $fact): string
62
+	{
63
+		$permission_level = $tree->getPreference('MAJ_CERTIF_SHOW_CERT');
64
+		if (is_numeric($permission_level) && Auth::accessLevel($tree) <= (int) $permission_level) {
65
+			$path = $this->extractPath($fact);
66 66
 
67
-            if ($path !== '') {
68
-                $certificate = new Certificate($tree, $path);
69
-                return view($this->module->name() . '::components/certificate-icon', [
70
-                    'module_name'               =>  $this->module->name(),
71
-                    'certificate'               =>  $certificate,
72
-                    'url_obfuscator_service'    =>  $this->url_obfuscator_service,
73
-                    'js_script_url'             =>  $this->module->assetUrl('js/certificates.min.js')
74
-                ]);
75
-            }
76
-        }
77
-        return '';
78
-    }
67
+			if ($path !== '') {
68
+				$certificate = new Certificate($tree, $path);
69
+				return view($this->module->name() . '::components/certificate-icon', [
70
+					'module_name'               =>  $this->module->name(),
71
+					'certificate'               =>  $certificate,
72
+					'url_obfuscator_service'    =>  $this->url_obfuscator_service,
73
+					'js_script_url'             =>  $this->module->assetUrl('js/certificates.min.js')
74
+				]);
75
+			}
76
+		}
77
+		return '';
78
+	}
79 79
 
80
-    /**
81
-     * Extract path from the provided fact objet.
82
-     *
83
-     * @param \Fisharebest\Webtrees\Fact|array<array<\Fisharebest\Webtrees\Contracts\ElementInterface|string>> $fact
84
-     * @return string
85
-     * @psalm-suppress RedundantConditionGivenDocblockType
86
-     */
87
-    private function extractPath($fact): string
88
-    {
89
-        if ($fact instanceof Fact && $fact->target() instanceof Source) {
90
-            return $fact->attribute('_ACT');
91
-        } elseif (
92
-            is_array($fact) && count($fact) === 2
93
-            && null !== ($source_elements = $fact[0]) && is_array($source_elements) // @phpstan-ignore-line
94
-            && null !== ($source_values = $fact[1]) && is_array($source_values) // @phpstan-ignore-line
95
-        ) {
96
-            foreach ($source_elements as $key => $element) {
97
-                if (
98
-                    $element instanceof SourceCertificate
99
-                    && isset($source_values[$key]) && is_string($source_values[$key])
100
-                ) {
101
-                    return $element->canonical($source_values[$key]);
102
-                }
103
-            }
104
-        }
105
-        return '';
106
-    }
80
+	/**
81
+	 * Extract path from the provided fact objet.
82
+	 *
83
+	 * @param \Fisharebest\Webtrees\Fact|array<array<\Fisharebest\Webtrees\Contracts\ElementInterface|string>> $fact
84
+	 * @return string
85
+	 * @psalm-suppress RedundantConditionGivenDocblockType
86
+	 */
87
+	private function extractPath($fact): string
88
+	{
89
+		if ($fact instanceof Fact && $fact->target() instanceof Source) {
90
+			return $fact->attribute('_ACT');
91
+		} elseif (
92
+			is_array($fact) && count($fact) === 2
93
+			&& null !== ($source_elements = $fact[0]) && is_array($source_elements) // @phpstan-ignore-line
94
+			&& null !== ($source_values = $fact[1]) && is_array($source_values) // @phpstan-ignore-line
95
+		) {
96
+			foreach ($source_elements as $key => $element) {
97
+				if (
98
+					$element instanceof SourceCertificate
99
+					&& isset($source_values[$key]) && is_string($source_values[$key])
100
+				) {
101
+					return $element->canonical($source_values[$key]);
102
+				}
103
+			}
104
+		}
105
+		return '';
106
+	}
107 107
 
108
-    /**
109
-     * {@inheritDoc}
110
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourceAppend()
111
-     */
112
-    public function factSourceAppend(Tree $tree, $fact): string
113
-    {
114
-        return '';
115
-    }
108
+	/**
109
+	 * {@inheritDoc}
110
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourceAppend()
111
+	 */
112
+	public function factSourceAppend(Tree $tree, $fact): string
113
+	{
114
+		return '';
115
+	}
116 116
 }
Please login to merge, or discard this patch.
app/Module/MiscExtensions/Http/RequestHandlers/AdminConfigAction.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -29,50 +29,50 @@
 block discarded – undo
29 29
  */
30 30
 class AdminConfigAction implements RequestHandlerInterface
31 31
 {
32
-    private ?MiscExtensionsModule $module;
32
+	private ?MiscExtensionsModule $module;
33 33
 
34
-    /**
35
-     * Constructor for AdminConfigPage Request Handler
36
-     *
37
-     * @param ModuleService $module_service
38
-     */
39
-    public function __construct(ModuleService $module_service)
40
-    {
41
-        $this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first();
42
-    }
34
+	/**
35
+	 * Constructor for AdminConfigPage Request Handler
36
+	 *
37
+	 * @param ModuleService $module_service
38
+	 */
39
+	public function __construct(ModuleService $module_service)
40
+	{
41
+		$this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first();
42
+	}
43 43
 
44
-    /**
45
-     * {@inheritDoc}
46
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
47
-     */
48
-    public function handle(ServerRequestInterface $request): ResponseInterface
49
-    {
50
-        if ($this->module === null) {
51
-            FlashMessages::addMessage(
52
-                I18N::translate('The attached module could not be found.'),
53
-                'danger'
54
-            );
55
-            return Registry::responseFactory()->redirect(AdminConfigPage::class);
56
-        }
44
+	/**
45
+	 * {@inheritDoc}
46
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
47
+	 */
48
+	public function handle(ServerRequestInterface $request): ResponseInterface
49
+	{
50
+		if ($this->module === null) {
51
+			FlashMessages::addMessage(
52
+				I18N::translate('The attached module could not be found.'),
53
+				'danger'
54
+			);
55
+			return Registry::responseFactory()->redirect(AdminConfigPage::class);
56
+		}
57 57
 
58
-        $this->module->setPreference(
59
-            'MAJ_TITLE_PREFIX',
60
-            Validator::parsedBody($request)->string('MAJ_TITLE_PREFIX', '')
61
-        );
62
-        $this->module->setPreference(
63
-            'MAJ_DISPLAY_CNIL',
64
-            Validator::parsedBody($request)->string('MAJ_DISPLAY_CNIL', '')
65
-        );
66
-        $this->module->setPreference(
67
-            'MAJ_CNIL_REFERENCE',
68
-            Validator::parsedBody($request)->string('MAJ_CNIL_REFERENCE', '')
69
-        );
58
+		$this->module->setPreference(
59
+			'MAJ_TITLE_PREFIX',
60
+			Validator::parsedBody($request)->string('MAJ_TITLE_PREFIX', '')
61
+		);
62
+		$this->module->setPreference(
63
+			'MAJ_DISPLAY_CNIL',
64
+			Validator::parsedBody($request)->string('MAJ_DISPLAY_CNIL', '')
65
+		);
66
+		$this->module->setPreference(
67
+			'MAJ_CNIL_REFERENCE',
68
+			Validator::parsedBody($request)->string('MAJ_CNIL_REFERENCE', '')
69
+		);
70 70
 
71
-        FlashMessages::addMessage(
72
-            I18N::translate('The preferences for the module “%s” have been updated.', $this->module->title()),
73
-            'success'
74
-        );
71
+		FlashMessages::addMessage(
72
+			I18N::translate('The preferences for the module “%s” have been updated.', $this->module->title()),
73
+			'success'
74
+		);
75 75
 
76
-        return Registry::responseFactory()->redirect(AdminConfigPage::class);
77
-    }
76
+		return Registry::responseFactory()->redirect(AdminConfigPage::class);
77
+	}
78 78
 }
Please login to merge, or discard this patch.
app/Module/Hooks/Http/RequestHandlers/ModulesHooksAction.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -31,58 +31,58 @@
 block discarded – undo
31 31
  */
32 32
 class ModulesHooksAction extends AbstractModuleComponentAction
33 33
 {
34
-    protected HookService $hook_service;
34
+	protected HookService $hook_service;
35 35
 
36
-    /**
37
-     * Constructor for ModulesHooksAction Request Handler
38
-     *
39
-     * @param ModuleService $module_service
40
-     * @param TreeService $tree_service
41
-     * @param HookService $hook_service
42
-     */
43
-    public function __construct(ModuleService $module_service, TreeService $tree_service, HookService $hook_service)
44
-    {
45
-        parent::__construct($module_service, $tree_service);
46
-        $this->hook_service = $hook_service;
47
-    }
36
+	/**
37
+	 * Constructor for ModulesHooksAction Request Handler
38
+	 *
39
+	 * @param ModuleService $module_service
40
+	 * @param TreeService $tree_service
41
+	 * @param HookService $hook_service
42
+	 */
43
+	public function __construct(ModuleService $module_service, TreeService $tree_service, HookService $hook_service)
44
+	{
45
+		parent::__construct($module_service, $tree_service);
46
+		$this->hook_service = $hook_service;
47
+	}
48 48
 
49
-    /**
50
-     * {@inheritDoc}
51
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
52
-     */
53
-    public function handle(ServerRequestInterface $request): ResponseInterface
54
-    {
55
-        $hook_name = Validator::attributes($request)->string('hook_name', '');
56
-        $hook_collector = $this->hook_service->find($hook_name, true);
57
-        if ($hook_collector === null) {
58
-            FlashMessages::addMessage(I18N::translate('The hook with name “%s” does not exist.', $hook_name), 'danger');
59
-            return Registry::responseFactory()->redirect(AdminConfigPage::class);
60
-        }
49
+	/**
50
+	 * {@inheritDoc}
51
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
52
+	 */
53
+	public function handle(ServerRequestInterface $request): ResponseInterface
54
+	{
55
+		$hook_name = Validator::attributes($request)->string('hook_name', '');
56
+		$hook_collector = $this->hook_service->find($hook_name, true);
57
+		if ($hook_collector === null) {
58
+			FlashMessages::addMessage(I18N::translate('The hook with name “%s” does not exist.', $hook_name), 'danger');
59
+			return Registry::responseFactory()->redirect(AdminConfigPage::class);
60
+		}
61 61
 
62
-        foreach ($hook_collector->hooks() as $hook) {
63
-            $this->updateStatus(get_class($hook->module()), $request);
64
-        }
62
+		foreach ($hook_collector->hooks() as $hook) {
63
+			$this->updateStatus(get_class($hook->module()), $request);
64
+		}
65 65
 
66
-        $this->updateHookOrder($hook_collector, $request);
66
+		$this->updateHookOrder($hook_collector, $request);
67 67
 
68
-        FlashMessages::addMessage(I18N::translate('The hook preferences have been updated.'), 'success');
68
+		FlashMessages::addMessage(I18N::translate('The hook preferences have been updated.'), 'success');
69 69
 
70
-        return Registry::responseFactory()->redirect(ModulesHooksPage::class, ['hook_name' => $hook_name]);
71
-    }
70
+		return Registry::responseFactory()->redirect(ModulesHooksPage::class, ['hook_name' => $hook_name]);
71
+	}
72 72
 
73
-    /**
74
-     * Update the order of modules for a hook interface.
75
-     *
76
-     * @param HookCollectorInterface $hook_collector
77
-     * @param ServerRequestInterface $request
78
-     */
79
-    protected function updateHookOrder(HookCollectorInterface $hook_collector, ServerRequestInterface $request): void
80
-    {
81
-        $order = Validator::parsedBody($request)->array('order');
82
-        $order = array_flip($order);
73
+	/**
74
+	 * Update the order of modules for a hook interface.
75
+	 *
76
+	 * @param HookCollectorInterface $hook_collector
77
+	 * @param ServerRequestInterface $request
78
+	 */
79
+	protected function updateHookOrder(HookCollectorInterface $hook_collector, ServerRequestInterface $request): void
80
+	{
81
+		$order = Validator::parsedBody($request)->array('order');
82
+		$order = array_flip($order);
83 83
 
84
-        foreach ($hook_collector->hooks() as $hook) {
85
-            $this->hook_service->updateOrder($hook_collector, $hook->module(), $order[$hook->module()->name()] ?? 0);
86
-        }
87
-    }
84
+		foreach ($hook_collector->hooks() as $hook) {
85
+			$this->hook_service->updateOrder($hook_collector, $hook->module(), $order[$hook->module()->name()] ?? 0);
86
+		}
87
+	}
88 88
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Http/RequestHandlers/SosaComputeAction.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -31,54 +31,54 @@
 block discarded – undo
31 31
  */
32 32
 class SosaComputeAction implements RequestHandlerInterface
33 33
 {
34
-    private UserService $user_service;
34
+	private UserService $user_service;
35 35
 
36
-    /**
37
-     * Constructor for SosaConfigAction Request Handler
38
-     *
39
-     * @param UserService $user_service
40
-     */
41
-    public function __construct(UserService $user_service)
42
-    {
43
-        $this->user_service = $user_service;
44
-    }
36
+	/**
37
+	 * Constructor for SosaConfigAction Request Handler
38
+	 *
39
+	 * @param UserService $user_service
40
+	 */
41
+	public function __construct(UserService $user_service)
42
+	{
43
+		$this->user_service = $user_service;
44
+	}
45 45
 
46
-    /**
47
-     * {@inheritDoc}
48
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
49
-     */
50
-    public function handle(ServerRequestInterface $request): ResponseInterface
51
-    {
52
-        $tree = Validator::attributes($request)->tree();
46
+	/**
47
+	 * {@inheritDoc}
48
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
49
+	 */
50
+	public function handle(ServerRequestInterface $request): ResponseInterface
51
+	{
52
+		$tree = Validator::attributes($request)->tree();
53 53
 
54
-        $user_id = Validator::parsedBody($request)->integer('user_id', Auth::id() ?? 0);
55
-        $partial_from = Validator::parsedBody($request)->isXref()->string('partial_from', '');
54
+		$user_id = Validator::parsedBody($request)->integer('user_id', Auth::id() ?? 0);
55
+		$partial_from = Validator::parsedBody($request)->isXref()->string('partial_from', '');
56 56
 
57
-        if (($user_id === -1 && Auth::isManager($tree)) || Auth::id() === $user_id) {
58
-            $user = $user_id === -1 ? new DefaultUser() : $this->user_service->find($user_id);
57
+		if (($user_id === -1 && Auth::isManager($tree)) || Auth::id() === $user_id) {
58
+			$user = $user_id === -1 ? new DefaultUser() : $this->user_service->find($user_id);
59 59
 
60
-            /** @var SosaCalculatorService $sosa_calc_service */
61
-            $sosa_calc_service = app()->makeWith(SosaCalculatorService::class, [ 'tree' => $tree, 'user' => $user]);
60
+			/** @var SosaCalculatorService $sosa_calc_service */
61
+			$sosa_calc_service = app()->makeWith(SosaCalculatorService::class, [ 'tree' => $tree, 'user' => $user]);
62 62
 
63
-            if (
64
-                $partial_from !== '' &&
65
-                ($sosa_from = Registry::individualFactory()->make($partial_from, $tree)) !== null
66
-            ) {
67
-                $res = $sosa_calc_service->computeFromIndividual($sosa_from);
68
-            } else {
69
-                $res = $sosa_calc_service->computeAll();
70
-            }
63
+			if (
64
+				$partial_from !== '' &&
65
+				($sosa_from = Registry::individualFactory()->make($partial_from, $tree)) !== null
66
+			) {
67
+				$res = $sosa_calc_service->computeFromIndividual($sosa_from);
68
+			} else {
69
+				$res = $sosa_calc_service->computeAll();
70
+			}
71 71
 
72
-            return $res ?
73
-                Registry::responseFactory()->response() :
74
-                Registry::responseFactory()->response(
75
-                    I18N::translate('An error occurred while computing Sosa ancestors.'),
76
-                    StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR
77
-                );
78
-        }
79
-        return Registry::responseFactory()->response(
80
-            I18N::translate('You do not have permission to modify the user.'),
81
-            StatusCodeInterface::STATUS_FORBIDDEN
82
-        );
83
-    }
72
+			return $res ?
73
+				Registry::responseFactory()->response() :
74
+				Registry::responseFactory()->response(
75
+					I18N::translate('An error occurred while computing Sosa ancestors.'),
76
+					StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR
77
+				);
78
+		}
79
+		return Registry::responseFactory()->response(
80
+			I18N::translate('You do not have permission to modify the user.'),
81
+			StatusCodeInterface::STATUS_FORBIDDEN
82
+		);
83
+	}
84 84
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Http/RequestHandlers/SosaConfig.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -33,71 +33,71 @@
 block discarded – undo
33 33
  */
34 34
 class SosaConfig implements RequestHandlerInterface
35 35
 {
36
-    use ViewResponseTrait;
36
+	use ViewResponseTrait;
37 37
 
38
-    /**
39
-     * @var SosaModule|null $module
40
-     */
41
-    private $module;
38
+	/**
39
+	 * @var SosaModule|null $module
40
+	 */
41
+	private $module;
42 42
 
43
-    /**
44
-     * Constructor for SosaConfig Request Handler
45
-     *
46
-     * @param ModuleService $module_service
47
-     */
48
-    public function __construct(ModuleService $module_service)
49
-    {
50
-        $this->module = $module_service->findByInterface(SosaModule::class)->first();
51
-    }
43
+	/**
44
+	 * Constructor for SosaConfig Request Handler
45
+	 *
46
+	 * @param ModuleService $module_service
47
+	 */
48
+	public function __construct(ModuleService $module_service)
49
+	{
50
+		$this->module = $module_service->findByInterface(SosaModule::class)->first();
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
-        $tree = Validator::attributes($request)->tree();
63
+		$tree = Validator::attributes($request)->tree();
64 64
 
65
-        $users_root = array();
66
-        if (Auth::check()) {
67
-            /** @var \Fisharebest\Webtrees\User $user */
68
-            $user = Auth::user();
69
-            $users_root[] = [
70
-                'user'      => $user,
71
-                'root_id'   => $tree->getUserPreference($user, 'MAJ_SOSA_ROOT_ID'),
72
-                'max_gen'   => $tree->getUserPreference($user, 'MAJ_SOSA_MAX_GEN')
73
-            ];
65
+		$users_root = array();
66
+		if (Auth::check()) {
67
+			/** @var \Fisharebest\Webtrees\User $user */
68
+			$user = Auth::user();
69
+			$users_root[] = [
70
+				'user'      => $user,
71
+				'root_id'   => $tree->getUserPreference($user, 'MAJ_SOSA_ROOT_ID'),
72
+				'max_gen'   => $tree->getUserPreference($user, 'MAJ_SOSA_MAX_GEN')
73
+			];
74 74
 
75
-            if (Auth::isManager($tree)) {
76
-                $default_user = new DefaultUser();
77
-                $users_root[] = [
78
-                    'user' => $default_user,
79
-                    'root_id' => $tree->getUserPreference($default_user, 'MAJ_SOSA_ROOT_ID'),
80
-                    'max_gen'   => $tree->getUserPreference($default_user, 'MAJ_SOSA_MAX_GEN')
81
-                ];
82
-            }
83
-        }
75
+			if (Auth::isManager($tree)) {
76
+				$default_user = new DefaultUser();
77
+				$users_root[] = [
78
+					'user' => $default_user,
79
+					'root_id' => $tree->getUserPreference($default_user, 'MAJ_SOSA_ROOT_ID'),
80
+					'max_gen'   => $tree->getUserPreference($default_user, 'MAJ_SOSA_MAX_GEN')
81
+				];
82
+			}
83
+		}
84 84
 
85
-        // Use the system max generations if not set
86
-        $max_gen_system = app(SosaRecordsService::class)->maxSystemGenerations();
87
-        foreach ($users_root as $key => $user_root) {
88
-            $users_root[$key]['max_gen'] = is_numeric($user_root['max_gen']) ?
89
-                (int) $user_root['max_gen'] :
90
-                $max_gen_system;
91
-        };
85
+		// Use the system max generations if not set
86
+		$max_gen_system = app(SosaRecordsService::class)->maxSystemGenerations();
87
+		foreach ($users_root as $key => $user_root) {
88
+			$users_root[$key]['max_gen'] = is_numeric($user_root['max_gen']) ?
89
+				(int) $user_root['max_gen'] :
90
+				$max_gen_system;
91
+		};
92 92
 
93
-        return $this->viewResponse($this->module->name() . '::config-page', [
94
-            'module_name'       =>  $this->module->name(),
95
-            'title'             =>  I18N::translate('Sosa Configuration'),
96
-            'tree'              =>  $tree,
97
-            'user_id'           =>  Validator::attributes($request)->user(),
98
-            'selected_user_id'  =>  Validator::queryParams($request)->integer('user_id', 0),
99
-            'immediate_compute' =>  Validator::queryParams($request)->string('compute', '') === 'yes',
100
-            'users_root'        =>  $users_root
101
-        ]);
102
-    }
93
+		return $this->viewResponse($this->module->name() . '::config-page', [
94
+			'module_name'       =>  $this->module->name(),
95
+			'title'             =>  I18N::translate('Sosa Configuration'),
96
+			'tree'              =>  $tree,
97
+			'user_id'           =>  Validator::attributes($request)->user(),
98
+			'selected_user_id'  =>  Validator::queryParams($request)->integer('user_id', 0),
99
+			'immediate_compute' =>  Validator::queryParams($request)->string('compute', '') === 'yes',
100
+			'users_root'        =>  $users_root
101
+		]);
102
+	}
103 103
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Http/RequestHandlers/SosaConfigAction.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -31,51 +31,51 @@
 block discarded – undo
31 31
  */
32 32
 class SosaConfigAction implements RequestHandlerInterface
33 33
 {
34
-    private UserService $user_service;
35
-    private SosaRecordsService $sosa_record_service;
34
+	private UserService $user_service;
35
+	private SosaRecordsService $sosa_record_service;
36 36
 
37
-    /**
38
-     * Constructor for SosaConfigAction Request Handler
39
-     *
40
-     * @param UserService $user_service
41
-     * @param SosaRecordsService $sosa_records_service
42
-     */
43
-    public function __construct(UserService $user_service, SosaRecordsService $sosa_records_service)
44
-    {
45
-        $this->user_service = $user_service;
46
-        $this->sosa_record_service = $sosa_records_service;
47
-    }
37
+	/**
38
+	 * Constructor for SosaConfigAction Request Handler
39
+	 *
40
+	 * @param UserService $user_service
41
+	 * @param SosaRecordsService $sosa_records_service
42
+	 */
43
+	public function __construct(UserService $user_service, SosaRecordsService $sosa_records_service)
44
+	{
45
+		$this->user_service = $user_service;
46
+		$this->sosa_record_service = $sosa_records_service;
47
+	}
48 48
 
49
-    /**
50
-     * {@inheritDoc}
51
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
52
-     */
53
-    public function handle(ServerRequestInterface $request): ResponseInterface
54
-    {
55
-        $tree = Validator::attributes($request)->tree();
49
+	/**
50
+	 * {@inheritDoc}
51
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
52
+	 */
53
+	public function handle(ServerRequestInterface $request): ResponseInterface
54
+	{
55
+		$tree = Validator::attributes($request)->tree();
56 56
 
57
-        $user_id = Validator::parsedBody($request)->integer('sosa-userid', -1);
58
-        $root_id = Validator::parsedBody($request)->isXref()->string('sosa-rootid', '');
59
-        $max_gen = Validator::parsedBody($request)->integer(
60
-            'sosa-maxgen',
61
-            $this->sosa_record_service->maxSystemGenerations()
62
-        );
57
+		$user_id = Validator::parsedBody($request)->integer('sosa-userid', -1);
58
+		$root_id = Validator::parsedBody($request)->isXref()->string('sosa-rootid', '');
59
+		$max_gen = Validator::parsedBody($request)->integer(
60
+			'sosa-maxgen',
61
+			$this->sosa_record_service->maxSystemGenerations()
62
+		);
63 63
 
64
-        if (Auth::id() === $user_id || ($user_id === -1 && Auth::isManager($tree))) {
65
-            $user = $user_id === -1 ? new DefaultUser() : $this->user_service->find($user_id);
66
-            if ($user !== null && ($root_indi = Registry::individualFactory()->make($root_id, $tree)) !== null) {
67
-                $tree->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $root_indi->xref());
68
-                $tree->setUserPreference($user, 'MAJ_SOSA_MAX_GEN', (string) $max_gen);
69
-                FlashMessages::addMessage(I18N::translate('The root individual has been updated.'));
70
-                return Registry::responseFactory()->redirect(SosaConfig::class, [
71
-                    'tree' => $tree->name(),
72
-                    'compute' => 'yes',
73
-                    'user_id' => $user_id
74
-                ]);
75
-            }
76
-        }
64
+		if (Auth::id() === $user_id || ($user_id === -1 && Auth::isManager($tree))) {
65
+			$user = $user_id === -1 ? new DefaultUser() : $this->user_service->find($user_id);
66
+			if ($user !== null && ($root_indi = Registry::individualFactory()->make($root_id, $tree)) !== null) {
67
+				$tree->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $root_indi->xref());
68
+				$tree->setUserPreference($user, 'MAJ_SOSA_MAX_GEN', (string) $max_gen);
69
+				FlashMessages::addMessage(I18N::translate('The root individual has been updated.'));
70
+				return Registry::responseFactory()->redirect(SosaConfig::class, [
71
+					'tree' => $tree->name(),
72
+					'compute' => 'yes',
73
+					'user_id' => $user_id
74
+				]);
75
+			}
76
+		}
77 77
 
78
-        FlashMessages::addMessage(I18N::translate('The root individual could not be updated.'), 'danger');
79
-        return Registry::responseFactory()->redirect(SosaConfig::class, ['tree' => $tree->name()]);
80
-    }
78
+		FlashMessages::addMessage(I18N::translate('The root individual could not be updated.'), 'danger');
79
+		return Registry::responseFactory()->redirect(SosaConfig::class, ['tree' => $tree->name()]);
80
+	}
81 81
 }
Please login to merge, or discard this patch.