Passed
Branch feature/2.1-geodispersion-dev (1d61a8)
by Jonathan
61:21
created

GeoDispersionModule::chartUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * webtrees-lib: MyArtJaub library for webtrees
5
 *
6
 * @package MyArtJaub\Webtrees
7
 * @subpackage GeoDispersion
8
 * @author Jonathan Jaubart <[email protected]>
9
 * @copyright Copyright (c) 2009-2021, Jonathan Jaubart
10
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3
11
 */
12
13
declare(strict_types=1);
14
15
namespace MyArtJaub\Webtrees\Module\GeoDispersion;
16
17
use Aura\Router\Map;
18
use Fisharebest\Webtrees\I18N;
19
use Fisharebest\Webtrees\Individual;
20
use Fisharebest\Webtrees\Module\AbstractModule;
21
use Fisharebest\Webtrees\Module\ModuleChartInterface;
22
use Fisharebest\Webtrees\Module\ModuleChartTrait;
23
use Fisharebest\Webtrees\Module\ModuleGlobalInterface;
24
use Fisharebest\Webtrees\Module\ModuleGlobalTrait;
25
use Fisharebest\Webtrees\Services\MigrationService;
26
use MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface;
27
use MyArtJaub\Webtrees\Contracts\GeoDispersion\ModulePlaceMapperProviderInterface;
28
use MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface;
29
use MyArtJaub\Webtrees\Module\ModuleMyArtJaubTrait;
30
use MyArtJaub\Webtrees\Module\GeoDispersion\GeoAnalyses\AllEventsByCenturyGeoAnalysis;
31
use MyArtJaub\Webtrees\Module\GeoDispersion\GeoAnalyses\AllEventsByTypeGeoAnalysis;
32
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewPage;
33
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewTabs;
34
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewsList;
35
use MyArtJaub\Webtrees\Module\GeoDispersion\PlaceMappers\CoordinatesPlaceMapper;
36
use MyArtJaub\Webtrees\Module\GeoDispersion\PlaceMappers\ReferenceTablePlaceMapper;
0 ignored issues
show
Bug introduced by
The type MyArtJaub\Webtrees\Modul...ferenceTablePlaceMapper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
37
use MyArtJaub\Webtrees\Module\GeoDispersion\PlaceMappers\SimplePlaceMapper;
38
use MyArtJaub\Webtrees\Module\GeoDispersion\PlaceMappers\SimpleTopFilteredPlaceMapper;
39
40
/**
41
 * Geographical Dispersion Module.
42
 */
43
class GeoDispersionModule extends AbstractModule implements
44
    ModuleMyArtJaubInterface,
45
    ModuleChartInterface,
46
    ModuleGlobalInterface,
47
    ModuleGeoAnalysisProviderInterface,
48
    ModulePlaceMapperProviderInterface
49
{
50
    use ModuleMyArtJaubTrait {
51
        boot as traitBoot;
52
    }
53
    use ModuleChartTrait;
54
    use ModuleGlobalTrait;
55
56
    // How to update the database schema for this module
57
    private const SCHEMA_TARGET_VERSION   = 2;
58
    private const SCHEMA_SETTING_NAME     = 'MAJ_GEODISP_SCHEMA_VERSION';
59
    private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema';
60
61
    /**
62
     * {@inheritDoc}
63
     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
64
     */
65
    public function title(): string
66
    {
67
        return /* I18N: Name of the “GeoDispersion” module */ I18N::translate('Geographical Dispersion');
68
    }
69
70
    /**
71
     * {@inheritDoc}
72
     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
73
     */
74
    public function description(): string
75
    {
76
        //phpcs:ignore Generic.Files.LineLength.TooLong
77
        return /* I18N: Description of the “GeoDispersion” module */ I18N::translate('Perform and display geographical dispersion analysis');
78
    }
79
80
    /**
81
     * {@inheritDoc}
82
     * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
83
     */
84
    public function boot(): void
85
    {
86
        $this->traitBoot();
87
        app(MigrationService::class)->updateSchema(
88
            self::SCHEMA_MIGRATION_PREFIX,
89
            self::SCHEMA_SETTING_NAME,
90
            self::SCHEMA_TARGET_VERSION
91
        );
92
    }
93
94
    /**
95
     * {@inheritDoc}
96
     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
97
     */
98
    public function customModuleVersion(): string
99
    {
100
        return '2.1.0-v.1';
101
    }
102
103
    /**
104
     * {@inheritDoc}
105
     * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
106
     */
107
    public function loadRoutes(Map $router): void
108
    {
109
        $router->attach('', '', static function (Map $router): void {
110
111
            $router->attach('', '/module-maj/geodispersion', static function (Map $router): void {
112
113
                $router->get(GeoAnalysisViewsList::class, '/list/{tree}', GeoAnalysisViewsList::class);
114
115
                $router->attach('', '/analysisview/{tree}/{view_id}', static function (Map $router): void {
116
                    $router->get(GeoAnalysisViewPage::class, '', GeoAnalysisViewPage::class);
117
                    $router->get(GeoAnalysisViewTabs::class, '/tabs', GeoAnalysisViewTabs::class);
118
                });
119
            });
120
        });
121
    }
122
123
    /**
124
     * {@inheritDoc}
125
     * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartUrl()
126
     */
127
    public function chartUrl(Individual $individual, array $parameters = []): string
128
    {
129
        return route(GeoAnalysisViewsList::class, ['tree' => $individual->tree()->name()] + $parameters);
130
    }
131
132
    /**
133
     * {@inheritDoc}
134
     * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartMenuClass()
135
     */
136
    public function chartMenuClass(): string
137
    {
138
        return 'menu-maj-geodispersion';
139
    }
140
141
    /**
142
     * {@inheritDoc}
143
     * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
144
     */
145
    public function headContent(): string
146
    {
147
        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
148
    }
149
150
    /**
151
     * {@inheritDoc}
152
     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModulePlaceMapperProviderInterface::listPlaceMappers()
153
     */
154
    public function listPlaceMappers(): array
155
    {
156
        return [
157
            CoordinatesPlaceMapper::class,
158
            SimplePlaceMapper::class,
159
            SimpleTopFilteredPlaceMapper::class
160
        ];
161
    }
162
163
    /**
164
     * {@inheritDoc}
165
     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface::listGeoAnalyses()
166
     */
167
    public function listGeoAnalyses(): array
168
    {
169
        return [
170
            AllEventsByCenturyGeoAnalysis::class,
171
            AllEventsByTypeGeoAnalysis::class
172
        ];
173
    }
174
}
175