Passed
Push — main ( f9aaf7...4197a4 )
by Jonathan
14:34
created
app/Module/Hooks/Services/HookService.php 1 patch
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -30,104 +30,104 @@
 block discarded – undo
30 30
  */
31 31
 class HookService implements HookServiceInterface
32 32
 {
33
-    private ModuleService $module_service;
33
+	private ModuleService $module_service;
34 34
 
35
-    /**
36
-     * Constructor for HookService
37
-     *
38
-     * @param ModuleService $module_service
39
-     */
40
-    public function __construct(ModuleService $module_service)
41
-    {
42
-        $this->module_service = $module_service;
43
-    }
35
+	/**
36
+	 * Constructor for HookService
37
+	 *
38
+	 * @param ModuleService $module_service
39
+	 */
40
+	public function __construct(ModuleService $module_service)
41
+	{
42
+		$this->module_service = $module_service;
43
+	}
44 44
 
45
-    /**
46
-     * {@inheritDoc}
47
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookServiceInterface::use()
48
-     */
49
-    public function use(string $hook_interface): ?HookCollectorInterface
50
-    {
51
-        return $this->all()->get($hook_interface);
52
-    }
45
+	/**
46
+	 * {@inheritDoc}
47
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookServiceInterface::use()
48
+	 */
49
+	public function use(string $hook_interface): ?HookCollectorInterface
50
+	{
51
+		return $this->all()->get($hook_interface);
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Find a hook collector by its name, with or without the disabled ones.
57
-     *
58
-     * @template THook of HookInterface
59
-     * @param string $hook_name
60
-     * @return HookCollectorInterface<THook>|null
61
-     */
62
-    public function find(string $hook_name, bool $include_disabled = false): ?HookCollectorInterface
63
-    {
64
-        return $this->all($include_disabled)
65
-            ->first(fn(HookCollectorInterface $hook_collector) => $hook_collector->name() === $hook_name);
66
-    }
55
+	/**
56
+	 * Find a hook collector by its name, with or without the disabled ones.
57
+	 *
58
+	 * @template THook of HookInterface
59
+	 * @param string $hook_name
60
+	 * @return HookCollectorInterface<THook>|null
61
+	 */
62
+	public function find(string $hook_name, bool $include_disabled = false): ?HookCollectorInterface
63
+	{
64
+		return $this->all($include_disabled)
65
+			->first(fn(HookCollectorInterface $hook_collector) => $hook_collector->name() === $hook_name);
66
+	}
67 67
 
68
-    /**
69
-     * Get all hook collectors subscribed by modules, with hooks ordered, with or without the disabled ones.
70
-     *
71
-     * @template THook of HookInterface
72
-     * @param bool $include_disabled
73
-     * @return Collection<string, HookCollectorInterface<THook>>
74
-     */
75
-    public function all(bool $include_disabled = false): Collection
76
-    {
77
-        return Registry::cache()->array()->remember('all-hooks', function () use ($include_disabled): Collection {
78
-            $hooks_info = DB::table('maj_hook_order')
79
-                ->get()
80
-                ->groupBy(['majho_hook_name', 'majho_module_name']);
68
+	/**
69
+	 * Get all hook collectors subscribed by modules, with hooks ordered, with or without the disabled ones.
70
+	 *
71
+	 * @template THook of HookInterface
72
+	 * @param bool $include_disabled
73
+	 * @return Collection<string, HookCollectorInterface<THook>>
74
+	 */
75
+	public function all(bool $include_disabled = false): Collection
76
+	{
77
+		return Registry::cache()->array()->remember('all-hooks', function () use ($include_disabled): Collection {
78
+			$hooks_info = DB::table('maj_hook_order')
79
+				->get()
80
+				->groupBy(['majho_hook_name', 'majho_module_name']);
81 81
 
82
-            $hooks = $this->module_service
83
-                ->findByInterface(ModuleHookSubscriberInterface::class, $include_disabled)
84
-                ->flatMap(fn(ModuleHookSubscriberInterface $module) => $module->listSubscribedHooks());
82
+			$hooks = $this->module_service
83
+				->findByInterface(ModuleHookSubscriberInterface::class, $include_disabled)
84
+				->flatMap(fn(ModuleHookSubscriberInterface $module) => $module->listSubscribedHooks());
85 85
 
86
-            $hook_collectors = collect();
87
-            $hook_instances = collect();
88
-            foreach ($hooks as $hook) {
89
-                if (!($hook instanceof HookInterface)) {
90
-                    continue;
91
-                }
92
-                if ($hook instanceof HookCollectorInterface) {
93
-                    $hook_collectors->put($hook->hookInterface(), $hook);
94
-                } else {
95
-                    $hook_instances->add($hook);
96
-                }
97
-            }
86
+			$hook_collectors = collect();
87
+			$hook_instances = collect();
88
+			foreach ($hooks as $hook) {
89
+				if (!($hook instanceof HookInterface)) {
90
+					continue;
91
+				}
92
+				if ($hook instanceof HookCollectorInterface) {
93
+					$hook_collectors->put($hook->hookInterface(), $hook);
94
+				} else {
95
+					$hook_instances->add($hook);
96
+				}
97
+			}
98 98
 
99
-            foreach ($hook_collectors as $hook_interface => $hook_collector) {
100
-                $hook_info = $hooks_info->get($hook_collector->name()) ?? collect();
101
-                foreach (
102
-                    $hook_instances->filter(
103
-                        fn(HookInterface $hook): bool => $hook instanceof $hook_interface
104
-                    ) as $hook_instance
105
-                ) {
106
-                    $hook_module_info = $hook_info->get($hook_instance->module()->name(), collect())->first();
107
-                    $hook_order = $hook_module_info instanceof stdClass ? (int) $hook_module_info->majho_hook_order : 0;
108
-                    $hook_collector->register($hook_instance, $hook_order);
109
-                }
110
-            }
111
-            return $hook_collectors;
112
-        });
113
-    }
99
+			foreach ($hook_collectors as $hook_interface => $hook_collector) {
100
+				$hook_info = $hooks_info->get($hook_collector->name()) ?? collect();
101
+				foreach (
102
+					$hook_instances->filter(
103
+						fn(HookInterface $hook): bool => $hook instanceof $hook_interface
104
+					) as $hook_instance
105
+				) {
106
+					$hook_module_info = $hook_info->get($hook_instance->module()->name(), collect())->first();
107
+					$hook_order = $hook_module_info instanceof stdClass ? (int) $hook_module_info->majho_hook_order : 0;
108
+					$hook_collector->register($hook_instance, $hook_order);
109
+				}
110
+			}
111
+			return $hook_collectors;
112
+		});
113
+	}
114 114
 
115
-    /**
116
-     * Update the order of the modules implementing a hook in the database.
117
-     *
118
-     * @template THook of HookInterface
119
-     * @param HookCollectorInterface<THook> $hook_collector
120
-     * @param ModuleInterface $module
121
-     * @param int $order
122
-     * @return int
123
-     */
124
-    public function updateOrder(HookCollectorInterface $hook_collector, ModuleInterface $module, int $order): int
125
-    {
126
-        return DB::table('maj_hook_order')
127
-            ->upsert([
128
-                'majho_module_name' =>  $module->name(),
129
-                'majho_hook_name'   =>  $hook_collector->name(),
130
-                'majho_hook_order'  =>  $order
131
-            ], ['majho_module_name', 'majho_hook_name'], ['majho_hook_order']);
132
-    }
115
+	/**
116
+	 * Update the order of the modules implementing a hook in the database.
117
+	 *
118
+	 * @template THook of HookInterface
119
+	 * @param HookCollectorInterface<THook> $hook_collector
120
+	 * @param ModuleInterface $module
121
+	 * @param int $order
122
+	 * @return int
123
+	 */
124
+	public function updateOrder(HookCollectorInterface $hook_collector, ModuleInterface $module, int $order): int
125
+	{
126
+		return DB::table('maj_hook_order')
127
+			->upsert([
128
+				'majho_module_name' =>  $module->name(),
129
+				'majho_hook_name'   =>  $hook_collector->name(),
130
+				'majho_hook_order'  =>  $order
131
+			], ['majho_module_name', 'majho_hook_name'], ['majho_hook_order']);
132
+	}
133 133
 }
Please login to merge, or discard this patch.
app/Module/MiscExtensions/Hooks/TitlesCardHook.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -25,68 +25,68 @@
 block discarded – undo
25 25
  */
26 26
 class TitlesCardHook implements NameAccordionExtenderInterface
27 27
 {
28
-    private ModuleInterface $module;
28
+	private ModuleInterface $module;
29 29
 
30
-    /**
31
-     * Constructor for TitlesCardHook
32
-     *
33
-     * @param ModuleInterface $module
34
-     */
35
-    public function __construct(ModuleInterface $module)
36
-    {
37
-        $this->module = $module;
38
-    }
30
+	/**
31
+	 * Constructor for TitlesCardHook
32
+	 *
33
+	 * @param ModuleInterface $module
34
+	 */
35
+	public function __construct(ModuleInterface $module)
36
+	{
37
+		$this->module = $module;
38
+	}
39 39
 
40
-    /**
41
-     * {@inheritDoc}
42
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module()
43
-     */
44
-    public function module(): ModuleInterface
45
-    {
46
-        return $this->module;
47
-    }
40
+	/**
41
+	 * {@inheritDoc}
42
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module()
43
+	 */
44
+	public function module(): ModuleInterface
45
+	{
46
+		return $this->module;
47
+	}
48 48
 
49
-    /**
50
-     * {@inheritDoc}
51
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\NameAccordionExtenderInterface::accordionCard()
52
-     */
53
-    public function accordionCard(Individual $individual): string
54
-    {
55
-        $title_separator = $this->module->getPreference('MAJ_TITLE_PREFIX');
56
-        if ($title_separator === '') {
57
-            return '';
58
-        }
49
+	/**
50
+	 * {@inheritDoc}
51
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\NameAccordionExtenderInterface::accordionCard()
52
+	 */
53
+	public function accordionCard(Individual $individual): string
54
+	{
55
+		$title_separator = $this->module->getPreference('MAJ_TITLE_PREFIX');
56
+		if ($title_separator === '') {
57
+			return '';
58
+		}
59 59
 
60
-        $titles = $this->individualTitles($individual, '/(.*?) ((' . $title_separator .  ')(.*))/i');
60
+		$titles = $this->individualTitles($individual, '/(.*?) ((' . $title_separator .  ')(.*))/i');
61 61
 
62
-        return count($titles) === 0 ? '' :
63
-            view($this->module()->name() . '::components/card-titles', [ 'titles' => $titles ]);
64
-    }
62
+		return count($titles) === 0 ? '' :
63
+			view($this->module()->name() . '::components/card-titles', [ 'titles' => $titles ]);
64
+	}
65 65
 
66
-    /**
67
-     * Extract the individual titles from the TITL tags.
68
-     * Split the title based on a pattern to identify the title and the land it refers to.
69
-     *
70
-     * @param Individual $individual
71
-     * @param string $pattern
72
-     * @return array<string, string[]>
73
-     */
74
-    protected function individualTitles(Individual $individual, string $pattern): array
75
-    {
76
-        $titles_list = [];
77
-        /** @var \Illuminate\Support\Collection<string> $titles */
78
-        $titles = $individual->facts(['TITL'])
79
-            ->sortByDesc(fn(Fact $fact) => $fact->date()->julianDay())
80
-            ->map(fn(Fact $fact) => $fact->value());
66
+	/**
67
+	 * Extract the individual titles from the TITL tags.
68
+	 * Split the title based on a pattern to identify the title and the land it refers to.
69
+	 *
70
+	 * @param Individual $individual
71
+	 * @param string $pattern
72
+	 * @return array<string, string[]>
73
+	 */
74
+	protected function individualTitles(Individual $individual, string $pattern): array
75
+	{
76
+		$titles_list = [];
77
+		/** @var \Illuminate\Support\Collection<string> $titles */
78
+		$titles = $individual->facts(['TITL'])
79
+			->sortByDesc(fn(Fact $fact) => $fact->date()->julianDay())
80
+			->map(fn(Fact $fact) => $fact->value());
81 81
 
82
-        foreach ($titles as $title) {
83
-            if (preg_match($pattern, $title, $match) === 1) {
84
-                /** @var array<int, string> $match */
85
-                $titles_list[$match[1]][] = trim($match[2]);
86
-            } else {
87
-                $titles_list[$title][] = '';
88
-            }
89
-        }
90
-        return $titles_list;
91
-    }
82
+		foreach ($titles as $title) {
83
+			if (preg_match($pattern, $title, $match) === 1) {
84
+				/** @var array<int, string> $match */
85
+				$titles_list[$match[1]][] = trim($match[2]);
86
+			} else {
87
+				$titles_list[$title][] = '';
88
+			}
89
+		}
90
+		return $titles_list;
91
+	}
92 92
 }
Please login to merge, or discard this patch.
app/Module/MiscExtensions/Http/RequestHandlers/AdminConfigAction.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -27,43 +27,43 @@
 block discarded – undo
27 27
  */
28 28
 class AdminConfigAction implements RequestHandlerInterface
29 29
 {
30
-    private ?MiscExtensionsModule $module;
30
+	private ?MiscExtensionsModule $module;
31 31
 
32
-    /**
33
-     * Constructor for AdminConfigPage Request Handler
34
-     *
35
-     * @param ModuleService $module_service
36
-     */
37
-    public function __construct(ModuleService $module_service)
38
-    {
39
-        $this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first();
40
-    }
32
+	/**
33
+	 * Constructor for AdminConfigPage Request Handler
34
+	 *
35
+	 * @param ModuleService $module_service
36
+	 */
37
+	public function __construct(ModuleService $module_service)
38
+	{
39
+		$this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first();
40
+	}
41 41
 
42
-    /**
43
-     * {@inheritDoc}
44
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
45
-     */
46
-    public function handle(ServerRequestInterface $request): ResponseInterface
47
-    {
48
-        if ($this->module === null) {
49
-            FlashMessages::addMessage(
50
-                I18N::translate('The attached module could not be found.'),
51
-                'danger'
52
-            );
53
-            return redirect(route(AdminConfigPage::class));
54
-        }
42
+	/**
43
+	 * {@inheritDoc}
44
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
45
+	 */
46
+	public function handle(ServerRequestInterface $request): ResponseInterface
47
+	{
48
+		if ($this->module === null) {
49
+			FlashMessages::addMessage(
50
+				I18N::translate('The attached module could not be found.'),
51
+				'danger'
52
+			);
53
+			return redirect(route(AdminConfigPage::class));
54
+		}
55 55
 
56
-        $params = (array) $request->getParsedBody();
56
+		$params = (array) $request->getParsedBody();
57 57
 
58
-        $this->module->setPreference('MAJ_TITLE_PREFIX', $params['MAJ_TITLE_PREFIX'] ?? '');
59
-        $this->module->setPreference('MAJ_DISPLAY_CNIL', $params['MAJ_DISPLAY_CNIL'] ?? '');
60
-        $this->module->setPreference('MAJ_CNIL_REFERENCE', $params['MAJ_CNIL_REFERENCE' ?? '']);
58
+		$this->module->setPreference('MAJ_TITLE_PREFIX', $params['MAJ_TITLE_PREFIX'] ?? '');
59
+		$this->module->setPreference('MAJ_DISPLAY_CNIL', $params['MAJ_DISPLAY_CNIL'] ?? '');
60
+		$this->module->setPreference('MAJ_CNIL_REFERENCE', $params['MAJ_CNIL_REFERENCE' ?? '']);
61 61
 
62
-        FlashMessages::addMessage(
63
-            I18N::translate('The preferences for the module “%s” have been updated.', $this->module->title()),
64
-            'success'
65
-        );
62
+		FlashMessages::addMessage(
63
+			I18N::translate('The preferences for the module “%s” have been updated.', $this->module->title()),
64
+			'success'
65
+		);
66 66
 
67
-        return redirect(route(AdminConfigPage::class));
68
-    }
67
+		return redirect(route(AdminConfigPage::class));
68
+	}
69 69
 }
Please login to merge, or discard this patch.
app/Module/MiscExtensions/Http/RequestHandlers/AdminConfigPage.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -28,35 +28,35 @@
 block discarded – undo
28 28
  */
29 29
 class AdminConfigPage implements RequestHandlerInterface
30 30
 {
31
-    use ViewResponseTrait;
32
-
33
-    private ?MiscExtensionsModule $module;
34
-
35
-    /**
36
-     * Constructor for AdminConfigPage Request Handler
37
-     *
38
-     * @param ModuleService $module_service
39
-     */
40
-    public function __construct(ModuleService $module_service)
41
-    {
42
-        $this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first();
43
-    }
44
-
45
-    /**
46
-     * {@inheritDoc}
47
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
48
-     */
49
-    public function handle(ServerRequestInterface $request): ResponseInterface
50
-    {
51
-        $this->layout = 'layouts/administration';
52
-
53
-        if ($this->module === null) {
54
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
55
-        }
56
-
57
-        return $this->viewResponse($this->module->name() . '::admin/config', [
58
-            'module'    =>  $this->module,
59
-            'title'     =>  $this->module->title()
60
-        ]);
61
-    }
31
+	use ViewResponseTrait;
32
+
33
+	private ?MiscExtensionsModule $module;
34
+
35
+	/**
36
+	 * Constructor for AdminConfigPage Request Handler
37
+	 *
38
+	 * @param ModuleService $module_service
39
+	 */
40
+	public function __construct(ModuleService $module_service)
41
+	{
42
+		$this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first();
43
+	}
44
+
45
+	/**
46
+	 * {@inheritDoc}
47
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
48
+	 */
49
+	public function handle(ServerRequestInterface $request): ResponseInterface
50
+	{
51
+		$this->layout = 'layouts/administration';
52
+
53
+		if ($this->module === null) {
54
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
55
+		}
56
+
57
+		return $this->viewResponse($this->module->name() . '::admin/config', [
58
+			'module'    =>  $this->module,
59
+			'title'     =>  $this->module->title()
60
+		]);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
app/Module/MiscExtensions/MiscExtensionsModule.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -32,89 +32,89 @@
 block discarded – undo
32 32
  * Provide miscellaneous improvements to webtrees.
33 33
  */
34 34
 class MiscExtensionsModule extends AbstractModule implements
35
-    ModuleMyArtJaubInterface,
36
-    ModuleConfigInterface,
37
-    ModuleHookSubscriberInterface
35
+	ModuleMyArtJaubInterface,
36
+	ModuleConfigInterface,
37
+	ModuleHookSubscriberInterface
38 38
 {
39
-    use ModuleMyArtJaubTrait {
40
-        boot as traitBoot;
41
-    }
42
-    use ModuleConfigTrait;
39
+	use ModuleMyArtJaubTrait {
40
+		boot as traitBoot;
41
+	}
42
+	use ModuleConfigTrait;
43 43
 
44
-    /**
45
-     * {@inheritDoc}
46
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
47
-     */
48
-    public function title(): string
49
-    {
50
-        return /* I18N: Name of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions');
51
-    }
44
+	/**
45
+	 * {@inheritDoc}
46
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
47
+	 */
48
+	public function title(): string
49
+	{
50
+		return /* I18N: Name of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions');
51
+	}
52 52
 
53
-    /**
54
-     * {@inheritDoc}
55
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
56
-     */
57
-    public function description(): string
58
-    {
59
-        //phpcs:ignore Generic.Files.LineLength.TooLong
60
-        return /* I18N: Description of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions for webtrees.');
61
-    }
53
+	/**
54
+	 * {@inheritDoc}
55
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
56
+	 */
57
+	public function description(): string
58
+	{
59
+		//phpcs:ignore Generic.Files.LineLength.TooLong
60
+		return /* I18N: Description of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions for webtrees.');
61
+	}
62 62
 
63
-    /**
64
-     * {@inheritDoc}
65
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
66
-     */
67
-    public function boot(): void
68
-    {
69
-        $this->traitBoot();
70
-        View::registerCustomView('::modules/privacy-policy/page', $this->name() . '::privacy-policy');
71
-    }
63
+	/**
64
+	 * {@inheritDoc}
65
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
66
+	 */
67
+	public function boot(): void
68
+	{
69
+		$this->traitBoot();
70
+		View::registerCustomView('::modules/privacy-policy/page', $this->name() . '::privacy-policy');
71
+	}
72 72
 
73
-    /**
74
-     * {@inheritDoc}
75
-     * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
76
-     */
77
-    public function loadRoutes(Map $router): void
78
-    {
79
-        $router->attach('', '', static function (Map $router): void {
73
+	/**
74
+	 * {@inheritDoc}
75
+	 * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
76
+	 */
77
+	public function loadRoutes(Map $router): void
78
+	{
79
+		$router->attach('', '', static function (Map $router): void {
80 80
 
81
-            $router->attach('', '/module-maj/misc', static function (Map $router): void {
81
+			$router->attach('', '/module-maj/misc', static function (Map $router): void {
82 82
 
83
-                $router->attach('', '/config/admin', static function (Map $router): void {
83
+				$router->attach('', '/config/admin', static function (Map $router): void {
84 84
 
85
-                    $router->get(AdminConfigPage::class, '', AdminConfigPage::class);
86
-                    $router->post(AdminConfigAction::class, '', AdminConfigAction::class);
87
-                });
88
-            });
89
-        });
90
-    }
85
+					$router->get(AdminConfigPage::class, '', AdminConfigPage::class);
86
+					$router->post(AdminConfigAction::class, '', AdminConfigAction::class);
87
+				});
88
+			});
89
+		});
90
+	}
91 91
 
92
-    /**
93
-     * {@inheritDoc}
94
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
95
-     */
96
-    public function customModuleVersion(): string
97
-    {
98
-        return '2.1.0-v.1';
99
-    }
92
+	/**
93
+	 * {@inheritDoc}
94
+	 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
95
+	 */
96
+	public function customModuleVersion(): string
97
+	{
98
+		return '2.1.0-v.1';
99
+	}
100 100
 
101
-    /**
102
-     * {@inheritDoc}
103
-     * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
104
-     */
105
-    public function getConfigLink(): string
106
-    {
107
-        return route(AdminConfigPage::class);
108
-    }
101
+	/**
102
+	 * {@inheritDoc}
103
+	 * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
104
+	 */
105
+	public function getConfigLink(): string
106
+	{
107
+		return route(AdminConfigPage::class);
108
+	}
109 109
 
110
-    /**
111
-     * {@inheritDoc}
112
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks()
113
-     */
114
-    public function listSubscribedHooks(): array
115
-    {
116
-        return [
117
-            app()->makeWith(TitlesCardHook::class, [ 'module' => $this ])
118
-        ];
119
-    }
110
+	/**
111
+	 * {@inheritDoc}
112
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks()
113
+	 */
114
+	public function listSubscribedHooks(): array
115
+	{
116
+		return [
117
+			app()->makeWith(TitlesCardHook::class, [ 'module' => $this ])
118
+		];
119
+	}
120 120
 }
Please login to merge, or discard this patch.
app/Module/Sosa/SosaModule.php 1 patch
Indentation   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -56,268 +56,268 @@
 block discarded – undo
56 56
  * Identify and produce statistics about Sosa ancestors
57 57
  */
58 58
 class SosaModule extends AbstractModule implements
59
-    ModuleMyArtJaubInterface,
60
-    ModuleGlobalInterface,
61
-    ModuleMenuInterface,
62
-    ModuleSidebarInterface,
63
-    ModuleGeoAnalysisProviderInterface,
64
-    ModuleHookSubscriberInterface
59
+	ModuleMyArtJaubInterface,
60
+	ModuleGlobalInterface,
61
+	ModuleMenuInterface,
62
+	ModuleSidebarInterface,
63
+	ModuleGeoAnalysisProviderInterface,
64
+	ModuleHookSubscriberInterface
65 65
 {
66
-    use ModuleMyArtJaubTrait {
67
-        boot as traitBoot;
68
-    }
69
-    use ModuleGlobalTrait;
70
-    use ModuleMenuTrait;
71
-    use ModuleSidebarTrait;
72
-
73
-    // How to update the database schema for this module
74
-    private const SCHEMA_TARGET_VERSION   = 3;
75
-    private const SCHEMA_SETTING_NAME     = 'MAJ_SOSA_SCHEMA_VERSION';
76
-    private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema';
66
+	use ModuleMyArtJaubTrait {
67
+		boot as traitBoot;
68
+	}
69
+	use ModuleGlobalTrait;
70
+	use ModuleMenuTrait;
71
+	use ModuleSidebarTrait;
72
+
73
+	// How to update the database schema for this module
74
+	private const SCHEMA_TARGET_VERSION   = 3;
75
+	private const SCHEMA_SETTING_NAME     = 'MAJ_SOSA_SCHEMA_VERSION';
76
+	private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema';
77 77
 /**
78
-     * {@inheritDoc}
79
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
80
-     */
81
-    public function title(): string
82
-    {
83
-        return /* I18N: Name of the “Sosa” module */ I18N::translate('Sosa');
84
-    }
85
-
86
-    /**
87
-     * {@inheritDoc}
88
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
89
-     */
90
-    public function description(): string
91
-    {
92
-        //phpcs:ignore Generic.Files.LineLength.TooLong
93
-        return /* I18N: Description of the “Sosa” module */ I18N::translate('Calculate and display Sosa ancestors of the root person.');
94
-    }
95
-
96
-    /**
97
-     * {@inheritDoc}
98
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
99
-     */
100
-    public function boot(): void
101
-    {
102
-        $this->traitBoot();
103
-        app(MigrationService::class)->updateSchema(
104
-            self::SCHEMA_MIGRATION_PREFIX,
105
-            self::SCHEMA_SETTING_NAME,
106
-            self::SCHEMA_TARGET_VERSION
107
-        );
108
-    }
109
-
110
-    /**
111
-     * {@inheritDoc}
112
-     * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
113
-     */
114
-    public function loadRoutes(Map $router): void
115
-    {
116
-        $router->attach('', '', static function (Map $router): void {
117
-
118
-            $router->attach('', '/module-maj/sosa', static function (Map $router): void {
119
-
120
-                $router->attach('', '/list', static function (Map $router): void {
121
-                    $router->tokens(['gen' => '\d+']);
122
-                    $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class);
123
-                    $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class);    //phpcs:ignore Generic.Files.LineLength.TooLong
124
-                    $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class);   //phpcs:ignore Generic.Files.LineLength.TooLong
125
-                    $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class);
126
-                });
127
-
128
-                $router->attach('', '/statistics/{tree}', static function (Map $router): void {
129
-
130
-                    $router->get(SosaStatistics::class, '', SosaStatistics::class);
131
-                    $router->get(PedigreeCollapseData::class, '/pedigreecollapse', PedigreeCollapseData::class);
132
-                });
133
-
134
-                $router->attach('', '/config/{tree}', static function (Map $router): void {
135
-
136
-                    $router->get(SosaConfig::class, '', SosaConfig::class);
137
-                    $router->post(SosaConfigAction::class, '', SosaConfigAction::class);
138
-                    $router->get(SosaComputeModal::class, '/compute/{xref}', SosaComputeModal::class);
139
-                    $router->post(SosaComputeAction::class, '/compute', SosaComputeAction::class);
140
-                });
141
-            });
142
-        });
143
-    }
144
-
145
-    /**
146
-     * {@inheritDoc}
147
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
148
-     */
149
-    public function customModuleVersion(): string
150
-    {
151
-        return '2.1.0-v.1';
152
-    }
153
-
154
-    /**
155
-     * {@inheritDoc}
156
-     * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::defaultMenuOrder()
157
-     */
158
-    public function defaultMenuOrder(): int
159
-    {
160
-        return 7;
161
-    }
162
-
163
-    /**
164
-     * {@inhericDoc}
165
-     * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::getMenu()
166
-     */
167
-    public function getMenu(Tree $tree): ?Menu
168
-    {
169
-        $menu = new Menu(I18N::translate('Sosa Statistics'));
170
-        $menu->setClass('menu-maj-sosa');
171
-        $menu->setSubmenus([
172
-            new Menu(
173
-                I18N::translate('Sosa Ancestors'),
174
-                route(AncestorsList::class, ['tree' => $tree->name()]),
175
-                'menu-maj-sosa-list',
176
-                ['rel' => 'nofollow']
177
-            ),
178
-            new Menu(
179
-                I18N::translate('Missing Ancestors'),
180
-                route(MissingAncestorsList::class, ['tree' => $tree->name()]),
181
-                'menu-maj-sosa-missing',
182
-                ['rel' => 'nofollow']
183
-            ),
184
-            new Menu(
185
-                I18N::translate('Sosa Statistics'),
186
-                route(SosaStatistics::class, ['tree' => $tree->name()]),
187
-                'menu-maj-sosa-stats'
188
-            )
189
-        ]);
190
-
191
-        if (Auth::check()) {
192
-            $menu->addSubmenu(new Menu(
193
-                I18N::translate('Sosa Configuration'),
194
-                route(SosaConfig::class, ['tree' => $tree->name()]),
195
-                'menu-maj-sosa-config'
196
-            ));
197
-
198
-            /** @var ServerRequestInterface $request */
199
-            $request = app(ServerRequestInterface::class);
200
-            $route = $request->getAttribute('route');
201
-            assert($route instanceof Route);
202
-
203
-            $root_indi_id = $tree->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID');
204
-
205
-            if ($route->name === IndividualPage::class && mb_strlen($root_indi_id) > 0) {
206
-                $xref = $request->getAttribute('xref');
207
-                assert(is_string($xref));
208
-
209
-                $menu->addSubmenu(new Menu(
210
-                    I18N::translate('Complete Sosas'),
211
-                    '#',
212
-                    'menu-maj-sosa-compute',
213
-                    [
214
-                        'rel'           => 'nofollow',
215
-                        'data-href'     => route(SosaComputeModal::class, ['tree' => $tree->name(), 'xref' => $xref]),
216
-                        'data-target'   => '#wt-ajax-modal',
217
-                        'data-toggle'   => 'modal',
218
-                        'data-backdrop' => 'static'
219
-                    ]
220
-                ));
221
-            }
222
-        }
223
-
224
-        return $menu;
225
-    }
226
-
227
-    /**
228
-     * {@inheritDoc}
229
-     * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
230
-     */
231
-    public function headContent(): string
232
-    {
233
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
234
-    }
235
-
236
-    /**
237
-     * {@inheritDoc}
238
-     * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::bodyContent()
239
-     */
240
-    public function bodyContent(): string
241
-    {
242
-        return '<script src="' . $this->assetUrl('js/sosa.min.js') . '"></script>';
243
-    }
244
-
245
-    /**
246
-     * {@inheritDoc}
247
-     * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::sidebarTitle()
248
-     */
249
-    public function sidebarTitle(): string
250
-    {
251
-        $request = app(ServerRequestInterface::class);
252
-        $xref = $request->getAttribute('xref');
253
-        $tree = $request->getAttribute('tree');
254
-        $user = Auth::check() ? Auth::user() : new DefaultUser();
255
-
256
-        $individual = Registry::individualFactory()->make($xref, $tree);
257
-
258
-        return view($this->name() . '::sidebar/title', [
259
-            'module_name'   =>  $this->name(),
260
-            'sosa_numbers'  =>  app(SosaRecordsService::class)->sosaNumbers($tree, $user, $individual)
261
-        ]);
262
-    }
263
-
264
-    /**
265
-     * {@inheritDoc}
266
-     * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::getSidebarContent()
267
-     */
268
-    public function getSidebarContent(Individual $individual): string
269
-    {
270
-        $sosa_root_xref = $individual->tree()->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID');
271
-        $sosa_root = Registry::individualFactory()->make($sosa_root_xref, $individual->tree());
272
-        $user = Auth::check() ? Auth::user() : new DefaultUser();
273
-
274
-        return view($this->name() . '::sidebar/content', [
275
-            'sosa_ancestor' =>  $individual,
276
-            'sosa_root'     =>  $sosa_root,
277
-            'sosa_numbers'  =>  app(SosaRecordsService::class)->sosaNumbers($individual->tree(), $user, $individual)
278
-        ]);
279
-    }
280
-
281
-    /**
282
-     * {@inheritDoc}
283
-     * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::hasSidebarContent()
284
-     */
285
-    public function hasSidebarContent(Individual $individual): bool
286
-    {
287
-        $user = Auth::check() ? Auth::user() : new DefaultUser();
288
-
289
-        return app(SosaRecordsService::class)
290
-            ->sosaNumbers($individual->tree(), $user, $individual)->count() > 0;
291
-    }
292
-
293
-    /**
294
-     * {@inheritDoc}
295
-     * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::defaultSidebarOrder()
296
-     */
297
-    public function defaultSidebarOrder(): int
298
-    {
299
-        return 1;
300
-    }
301
-
302
-    /**
303
-     * {@inheritDoc}
304
-     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface::listGeoAnalyses()
305
-     */
306
-    public function listGeoAnalyses(): array
307
-    {
308
-        return [
309
-            SosaByGenerationGeoAnalysis::class
310
-        ];
311
-    }
312
-
313
-    /**
314
-     * {@inheritDoc}
315
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks()
316
-     */
317
-    public function listSubscribedHooks(): array
318
-    {
319
-        return [
320
-            app()->makeWith(SosaIconHook::class, [ 'module' => $this ])
321
-        ];
322
-    }
78
+	 * {@inheritDoc}
79
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
80
+	 */
81
+	public function title(): string
82
+	{
83
+		return /* I18N: Name of the “Sosa” module */ I18N::translate('Sosa');
84
+	}
85
+
86
+	/**
87
+	 * {@inheritDoc}
88
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
89
+	 */
90
+	public function description(): string
91
+	{
92
+		//phpcs:ignore Generic.Files.LineLength.TooLong
93
+		return /* I18N: Description of the “Sosa” module */ I18N::translate('Calculate and display Sosa ancestors of the root person.');
94
+	}
95
+
96
+	/**
97
+	 * {@inheritDoc}
98
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
99
+	 */
100
+	public function boot(): void
101
+	{
102
+		$this->traitBoot();
103
+		app(MigrationService::class)->updateSchema(
104
+			self::SCHEMA_MIGRATION_PREFIX,
105
+			self::SCHEMA_SETTING_NAME,
106
+			self::SCHEMA_TARGET_VERSION
107
+		);
108
+	}
109
+
110
+	/**
111
+	 * {@inheritDoc}
112
+	 * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
113
+	 */
114
+	public function loadRoutes(Map $router): void
115
+	{
116
+		$router->attach('', '', static function (Map $router): void {
117
+
118
+			$router->attach('', '/module-maj/sosa', static function (Map $router): void {
119
+
120
+				$router->attach('', '/list', static function (Map $router): void {
121
+					$router->tokens(['gen' => '\d+']);
122
+					$router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class);
123
+					$router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class);    //phpcs:ignore Generic.Files.LineLength.TooLong
124
+					$router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class);   //phpcs:ignore Generic.Files.LineLength.TooLong
125
+					$router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class);
126
+				});
127
+
128
+				$router->attach('', '/statistics/{tree}', static function (Map $router): void {
129
+
130
+					$router->get(SosaStatistics::class, '', SosaStatistics::class);
131
+					$router->get(PedigreeCollapseData::class, '/pedigreecollapse', PedigreeCollapseData::class);
132
+				});
133
+
134
+				$router->attach('', '/config/{tree}', static function (Map $router): void {
135
+
136
+					$router->get(SosaConfig::class, '', SosaConfig::class);
137
+					$router->post(SosaConfigAction::class, '', SosaConfigAction::class);
138
+					$router->get(SosaComputeModal::class, '/compute/{xref}', SosaComputeModal::class);
139
+					$router->post(SosaComputeAction::class, '/compute', SosaComputeAction::class);
140
+				});
141
+			});
142
+		});
143
+	}
144
+
145
+	/**
146
+	 * {@inheritDoc}
147
+	 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
148
+	 */
149
+	public function customModuleVersion(): string
150
+	{
151
+		return '2.1.0-v.1';
152
+	}
153
+
154
+	/**
155
+	 * {@inheritDoc}
156
+	 * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::defaultMenuOrder()
157
+	 */
158
+	public function defaultMenuOrder(): int
159
+	{
160
+		return 7;
161
+	}
162
+
163
+	/**
164
+	 * {@inhericDoc}
165
+	 * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::getMenu()
166
+	 */
167
+	public function getMenu(Tree $tree): ?Menu
168
+	{
169
+		$menu = new Menu(I18N::translate('Sosa Statistics'));
170
+		$menu->setClass('menu-maj-sosa');
171
+		$menu->setSubmenus([
172
+			new Menu(
173
+				I18N::translate('Sosa Ancestors'),
174
+				route(AncestorsList::class, ['tree' => $tree->name()]),
175
+				'menu-maj-sosa-list',
176
+				['rel' => 'nofollow']
177
+			),
178
+			new Menu(
179
+				I18N::translate('Missing Ancestors'),
180
+				route(MissingAncestorsList::class, ['tree' => $tree->name()]),
181
+				'menu-maj-sosa-missing',
182
+				['rel' => 'nofollow']
183
+			),
184
+			new Menu(
185
+				I18N::translate('Sosa Statistics'),
186
+				route(SosaStatistics::class, ['tree' => $tree->name()]),
187
+				'menu-maj-sosa-stats'
188
+			)
189
+		]);
190
+
191
+		if (Auth::check()) {
192
+			$menu->addSubmenu(new Menu(
193
+				I18N::translate('Sosa Configuration'),
194
+				route(SosaConfig::class, ['tree' => $tree->name()]),
195
+				'menu-maj-sosa-config'
196
+			));
197
+
198
+			/** @var ServerRequestInterface $request */
199
+			$request = app(ServerRequestInterface::class);
200
+			$route = $request->getAttribute('route');
201
+			assert($route instanceof Route);
202
+
203
+			$root_indi_id = $tree->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID');
204
+
205
+			if ($route->name === IndividualPage::class && mb_strlen($root_indi_id) > 0) {
206
+				$xref = $request->getAttribute('xref');
207
+				assert(is_string($xref));
208
+
209
+				$menu->addSubmenu(new Menu(
210
+					I18N::translate('Complete Sosas'),
211
+					'#',
212
+					'menu-maj-sosa-compute',
213
+					[
214
+						'rel'           => 'nofollow',
215
+						'data-href'     => route(SosaComputeModal::class, ['tree' => $tree->name(), 'xref' => $xref]),
216
+						'data-target'   => '#wt-ajax-modal',
217
+						'data-toggle'   => 'modal',
218
+						'data-backdrop' => 'static'
219
+					]
220
+				));
221
+			}
222
+		}
223
+
224
+		return $menu;
225
+	}
226
+
227
+	/**
228
+	 * {@inheritDoc}
229
+	 * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
230
+	 */
231
+	public function headContent(): string
232
+	{
233
+		return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
234
+	}
235
+
236
+	/**
237
+	 * {@inheritDoc}
238
+	 * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::bodyContent()
239
+	 */
240
+	public function bodyContent(): string
241
+	{
242
+		return '<script src="' . $this->assetUrl('js/sosa.min.js') . '"></script>';
243
+	}
244
+
245
+	/**
246
+	 * {@inheritDoc}
247
+	 * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::sidebarTitle()
248
+	 */
249
+	public function sidebarTitle(): string
250
+	{
251
+		$request = app(ServerRequestInterface::class);
252
+		$xref = $request->getAttribute('xref');
253
+		$tree = $request->getAttribute('tree');
254
+		$user = Auth::check() ? Auth::user() : new DefaultUser();
255
+
256
+		$individual = Registry::individualFactory()->make($xref, $tree);
257
+
258
+		return view($this->name() . '::sidebar/title', [
259
+			'module_name'   =>  $this->name(),
260
+			'sosa_numbers'  =>  app(SosaRecordsService::class)->sosaNumbers($tree, $user, $individual)
261
+		]);
262
+	}
263
+
264
+	/**
265
+	 * {@inheritDoc}
266
+	 * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::getSidebarContent()
267
+	 */
268
+	public function getSidebarContent(Individual $individual): string
269
+	{
270
+		$sosa_root_xref = $individual->tree()->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID');
271
+		$sosa_root = Registry::individualFactory()->make($sosa_root_xref, $individual->tree());
272
+		$user = Auth::check() ? Auth::user() : new DefaultUser();
273
+
274
+		return view($this->name() . '::sidebar/content', [
275
+			'sosa_ancestor' =>  $individual,
276
+			'sosa_root'     =>  $sosa_root,
277
+			'sosa_numbers'  =>  app(SosaRecordsService::class)->sosaNumbers($individual->tree(), $user, $individual)
278
+		]);
279
+	}
280
+
281
+	/**
282
+	 * {@inheritDoc}
283
+	 * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::hasSidebarContent()
284
+	 */
285
+	public function hasSidebarContent(Individual $individual): bool
286
+	{
287
+		$user = Auth::check() ? Auth::user() : new DefaultUser();
288
+
289
+		return app(SosaRecordsService::class)
290
+			->sosaNumbers($individual->tree(), $user, $individual)->count() > 0;
291
+	}
292
+
293
+	/**
294
+	 * {@inheritDoc}
295
+	 * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::defaultSidebarOrder()
296
+	 */
297
+	public function defaultSidebarOrder(): int
298
+	{
299
+		return 1;
300
+	}
301
+
302
+	/**
303
+	 * {@inheritDoc}
304
+	 * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface::listGeoAnalyses()
305
+	 */
306
+	public function listGeoAnalyses(): array
307
+	{
308
+		return [
309
+			SosaByGenerationGeoAnalysis::class
310
+		];
311
+	}
312
+
313
+	/**
314
+	 * {@inheritDoc}
315
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks()
316
+	 */
317
+	public function listSubscribedHooks(): array
318
+	{
319
+		return [
320
+			app()->makeWith(SosaIconHook::class, [ 'module' => $this ])
321
+		];
322
+	}
323 323
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Hooks/SosaIconHook.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -26,51 +26,51 @@
 block discarded – undo
26 26
  */
27 27
 class SosaIconHook implements RecordNameTextExtenderInterface
28 28
 {
29
-    private ModuleInterface $module;
30
-    private SosaRecordsService $sosa_records_service;
29
+	private ModuleInterface $module;
30
+	private SosaRecordsService $sosa_records_service;
31 31
 
32
-    /**
33
-     * Constructor for SosaIconHook
34
-     *
35
-     * @param ModuleInterface $module
36
-     * @param SosaRecordsService $sosa_records_service
37
-     */
38
-    public function __construct(ModuleInterface $module, SosaRecordsService $sosa_records_service)
39
-    {
40
-        $this->module = $module;
41
-        $this->sosa_records_service = $sosa_records_service;
42
-    }
32
+	/**
33
+	 * Constructor for SosaIconHook
34
+	 *
35
+	 * @param ModuleInterface $module
36
+	 * @param SosaRecordsService $sosa_records_service
37
+	 */
38
+	public function __construct(ModuleInterface $module, SosaRecordsService $sosa_records_service)
39
+	{
40
+		$this->module = $module;
41
+		$this->sosa_records_service = $sosa_records_service;
42
+	}
43 43
 
44
-    /**
45
-     * {@inheritDoc}
46
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module()
47
-     */
48
-    public function module(): ModuleInterface
49
-    {
50
-        return $this->module;
51
-    }
44
+	/**
45
+	 * {@inheritDoc}
46
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module()
47
+	 */
48
+	public function module(): ModuleInterface
49
+	{
50
+		return $this->module;
51
+	}
52 52
 
53
-    /**
54
-     * {@inheritDoc}
55
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend()
56
-     */
57
-    public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string
58
-    {
59
-        return '';
60
-    }
53
+	/**
54
+	 * {@inheritDoc}
55
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend()
56
+	 */
57
+	public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string
58
+	{
59
+		return '';
60
+	}
61 61
 
62
-    /**
63
-     * {@inheritDoc}
64
-     * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend()
65
-     */
66
-    public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string
67
-    {
68
-        if (
69
-            $record instanceof Individual &&
70
-            $this->sosa_records_service->isSosa($record->tree(), Auth::user(), $record)
71
-        ) {
72
-            return view($this->module->name() . '::icons/sosa', [ 'size_style' => $size ]);
73
-        }
74
-        return '';
75
-    }
62
+	/**
63
+	 * {@inheritDoc}
64
+	 * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend()
65
+	 */
66
+	public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string
67
+	{
68
+		if (
69
+			$record instanceof Individual &&
70
+			$this->sosa_records_service->isSosa($record->tree(), Auth::user(), $record)
71
+		) {
72
+			return view($this->module->name() . '::icons/sosa', [ 'size_style' => $size ]);
73
+		}
74
+		return '';
75
+	}
76 76
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Data/MissingAncestor.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -21,79 +21,79 @@
 block discarded – undo
21 21
  */
22 22
 class MissingAncestor
23 23
 {
24
-    /**
25
-     * @var Individual $individual
26
-     */
27
-    private $individual;
24
+	/**
25
+	 * @var Individual $individual
26
+	 */
27
+	private $individual;
28 28
 
29
-    /**
30
-     * @var int $sosa
31
-     */
32
-    private $sosa;
29
+	/**
30
+	 * @var int $sosa
31
+	 */
32
+	private $sosa;
33 33
 
34
-    /**
35
-     * @var bool $missing_father
36
-     */
37
-    private $missing_father;
34
+	/**
35
+	 * @var bool $missing_father
36
+	 */
37
+	private $missing_father;
38 38
 
39
-    /**
40
-     * @var bool $missing_mother
41
-     */
42
-    private $missing_mother;
39
+	/**
40
+	 * @var bool $missing_mother
41
+	 */
42
+	private $missing_mother;
43 43
 
44
-    /**
45
-     * Constructor for MissingAncestor data class
46
-     *
47
-     * @param Individual $ancestor
48
-     * @param int $sosa
49
-     * @param bool $missing_father
50
-     * @param bool $missing_mother
51
-     */
52
-    public function __construct(Individual $ancestor, int $sosa, bool $missing_father, bool $missing_mother)
53
-    {
54
-        $this->individual = $ancestor;
55
-        $this->sosa = $sosa;
56
-        $this->missing_father = $missing_father;
57
-        $this->missing_mother = $missing_mother;
58
-    }
44
+	/**
45
+	 * Constructor for MissingAncestor data class
46
+	 *
47
+	 * @param Individual $ancestor
48
+	 * @param int $sosa
49
+	 * @param bool $missing_father
50
+	 * @param bool $missing_mother
51
+	 */
52
+	public function __construct(Individual $ancestor, int $sosa, bool $missing_father, bool $missing_mother)
53
+	{
54
+		$this->individual = $ancestor;
55
+		$this->sosa = $sosa;
56
+		$this->missing_father = $missing_father;
57
+		$this->missing_mother = $missing_mother;
58
+	}
59 59
 
60
-    /**
61
-     * Reference individual of the row
62
-     *
63
-     * @return Individual
64
-     */
65
-    public function individual(): Individual
66
-    {
67
-        return $this->individual;
68
-    }
60
+	/**
61
+	 * Reference individual of the row
62
+	 *
63
+	 * @return Individual
64
+	 */
65
+	public function individual(): Individual
66
+	{
67
+		return $this->individual;
68
+	}
69 69
 
70
-    /**
71
-     * Minimum sosa of the reference individual
72
-     *
73
-     * @return int
74
-     */
75
-    public function sosa(): int
76
-    {
77
-        return $this->sosa;
78
-    }
70
+	/**
71
+	 * Minimum sosa of the reference individual
72
+	 *
73
+	 * @return int
74
+	 */
75
+	public function sosa(): int
76
+	{
77
+		return $this->sosa;
78
+	}
79 79
 
80
-    /**
81
-     * Indicate whether the reference individual does not have a father
82
-     *
83
-     * @return bool
84
-     */
85
-    public function isFatherMissing(): bool
86
-    {
87
-        return $this->missing_father;
88
-    }
80
+	/**
81
+	 * Indicate whether the reference individual does not have a father
82
+	 *
83
+	 * @return bool
84
+	 */
85
+	public function isFatherMissing(): bool
86
+	{
87
+		return $this->missing_father;
88
+	}
89 89
 
90
-    /**
91
-     * Indicate whether the reference individual does not have a mother
92
-     *
93
-     * @return bool
94
-     */
95
-    public function isMotherMissing(): bool
96
-    {
97
-        return $this->missing_mother;
98
-    }
90
+	/**
91
+	 * Indicate whether the reference individual does not have a mother
92
+	 *
93
+	 * @return bool
94
+	 */
95
+	public function isMotherMissing(): bool
96
+	{
97
+		return $this->missing_mother;
98
+	}
99 99
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Http/RequestHandlers/AncestorsListIndividual.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -35,74 +35,74 @@
 block discarded – undo
35 35
  */
36 36
 class AncestorsListIndividual implements RequestHandlerInterface
37 37
 {
38
-    use ViewResponseTrait;
39
-
40
-    /**
41
-     * @var SosaModule|null $module
42
-     */
43
-    private $module;
44
-
45
-    /**
46
-     * @var SosaRecordsService $sosa_record_service
47
-     */
48
-    private $sosa_record_service;
49
-
50
-    /**
51
-     * Constructor for AncestorsListIndividual Request Handler
52
-     *
53
-     * @param ModuleService $module_service
54
-     * @param SosaRecordsService $sosa_record_service
55
-     */
56
-    public function __construct(
57
-        ModuleService $module_service,
58
-        SosaRecordsService $sosa_record_service
59
-    ) {
60
-        $this->module = $module_service->findByInterface(SosaModule::class)->first();
61
-        $this->sosa_record_service = $sosa_record_service;
62
-    }
63
-
64
-    /**
65
-     * {@inheritDoc}
66
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
67
-     */
68
-    public function handle(ServerRequestInterface $request): ResponseInterface
69
-    {
70
-        $this->layout = 'layouts/ajax';
71
-
72
-        if ($this->module === null) {
73
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
74
-        }
75
-
76
-        $tree = $request->getAttribute('tree');
77
-        assert($tree instanceof Tree);
78
-
79
-        $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser();
80
-
81
-        $current_gen = (int) ($request->getAttribute('gen') ?? 0);
82
-
83
-        if ($current_gen <= 0) {
84
-            return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY);
85
-        }
86
-
87
-        $list_ancestors = $this->sosa_record_service->listAncestorsAtGeneration($tree, $user, $current_gen);
88
-        $nb_ancestors_all = $list_ancestors->count();
89
-
90
-        /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */
91
-        $list_ancestors = $list_ancestors->mapWithKeys(function (stdClass $value) use ($tree): ?array {
92
-                $indi = Registry::individualFactory()->make($value->majs_i_id, $tree);
93
-                return ($indi !== null && $indi->canShowName()) ? [(int) $value->majs_sosa => $indi] : null;
94
-        })->filter();
95
-
96
-        $nb_ancestors_shown = $list_ancestors->count();
97
-
98
-        return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [
99
-            'module_name'       =>  $this->module->name(),
100
-            'title'             =>  I18N::translate('Sosa Ancestors'),
101
-            'tree'              =>  $tree,
102
-            'list_ancestors'    =>  $list_ancestors,
103
-            'nb_ancestors_all'  =>  $nb_ancestors_all,
104
-            'nb_ancestors_theor' =>  pow(2, $current_gen - 1),
105
-            'nb_ancestors_shown' =>  $nb_ancestors_shown
106
-        ]);
107
-    }
38
+	use ViewResponseTrait;
39
+
40
+	/**
41
+	 * @var SosaModule|null $module
42
+	 */
43
+	private $module;
44
+
45
+	/**
46
+	 * @var SosaRecordsService $sosa_record_service
47
+	 */
48
+	private $sosa_record_service;
49
+
50
+	/**
51
+	 * Constructor for AncestorsListIndividual Request Handler
52
+	 *
53
+	 * @param ModuleService $module_service
54
+	 * @param SosaRecordsService $sosa_record_service
55
+	 */
56
+	public function __construct(
57
+		ModuleService $module_service,
58
+		SosaRecordsService $sosa_record_service
59
+	) {
60
+		$this->module = $module_service->findByInterface(SosaModule::class)->first();
61
+		$this->sosa_record_service = $sosa_record_service;
62
+	}
63
+
64
+	/**
65
+	 * {@inheritDoc}
66
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
67
+	 */
68
+	public function handle(ServerRequestInterface $request): ResponseInterface
69
+	{
70
+		$this->layout = 'layouts/ajax';
71
+
72
+		if ($this->module === null) {
73
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
74
+		}
75
+
76
+		$tree = $request->getAttribute('tree');
77
+		assert($tree instanceof Tree);
78
+
79
+		$user = Auth::check() ? $request->getAttribute('user') : new DefaultUser();
80
+
81
+		$current_gen = (int) ($request->getAttribute('gen') ?? 0);
82
+
83
+		if ($current_gen <= 0) {
84
+			return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY);
85
+		}
86
+
87
+		$list_ancestors = $this->sosa_record_service->listAncestorsAtGeneration($tree, $user, $current_gen);
88
+		$nb_ancestors_all = $list_ancestors->count();
89
+
90
+		/** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */
91
+		$list_ancestors = $list_ancestors->mapWithKeys(function (stdClass $value) use ($tree): ?array {
92
+				$indi = Registry::individualFactory()->make($value->majs_i_id, $tree);
93
+				return ($indi !== null && $indi->canShowName()) ? [(int) $value->majs_sosa => $indi] : null;
94
+		})->filter();
95
+
96
+		$nb_ancestors_shown = $list_ancestors->count();
97
+
98
+		return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [
99
+			'module_name'       =>  $this->module->name(),
100
+			'title'             =>  I18N::translate('Sosa Ancestors'),
101
+			'tree'              =>  $tree,
102
+			'list_ancestors'    =>  $list_ancestors,
103
+			'nb_ancestors_all'  =>  $nb_ancestors_all,
104
+			'nb_ancestors_theor' =>  pow(2, $current_gen - 1),
105
+			'nb_ancestors_shown' =>  $nb_ancestors_shown
106
+		]);
107
+	}
108 108
 }
Please login to merge, or discard this patch.