jon48 /
webtrees-lib
| 1 | <?php |
||||
| 2 | |||||
| 3 | /** |
||||
| 4 | * webtrees-lib: MyArtJaub library for webtrees |
||||
| 5 | * |
||||
| 6 | * @package MyArtJaub\Webtrees |
||||
| 7 | * @author Jonathan Jaubart <[email protected]> |
||||
| 8 | * @copyright Copyright (c) 2020-2022, Jonathan Jaubart |
||||
| 9 | * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
||||
| 10 | */ |
||||
| 11 | |||||
| 12 | declare(strict_types=1); |
||||
| 13 | |||||
| 14 | namespace MyArtJaub\Webtrees\Module; |
||||
| 15 | |||||
| 16 | use Aura\Router\Map; |
||||
| 17 | use Aura\Router\RouterContainer; |
||||
| 18 | use Fisharebest\Localization\Translation; |
||||
| 19 | use Fisharebest\Webtrees\View; |
||||
| 20 | use Fisharebest\Webtrees\Webtrees; |
||||
| 21 | use Fisharebest\Webtrees\Module\ModuleCustomTrait; |
||||
| 22 | use Fisharebest\Webtrees\Module\ModuleThemeInterface; |
||||
| 23 | |||||
| 24 | /** |
||||
| 25 | * MyArtJaub Module |
||||
| 26 | */ |
||||
| 27 | trait ModuleMyArtJaubTrait |
||||
| 28 | { |
||||
| 29 | use ModuleCustomTrait; |
||||
| 30 | |||||
| 31 | /** |
||||
| 32 | * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
||||
| 33 | */ |
||||
| 34 | public function boot(): void |
||||
| 35 | { |
||||
| 36 | View::registerNamespace($this->name(), $this->resourcesFolder() . 'views/'); |
||||
| 37 | |||||
| 38 | $this->loadRoutes(app(RouterContainer::class)->getMap()); |
||||
| 39 | } |
||||
| 40 | |||||
| 41 | /** |
||||
| 42 | * @see \Fisharebest\Webtrees\Module\AbstractModule::resourcesFolder() |
||||
| 43 | */ |
||||
| 44 | public function resourcesFolder(): string |
||||
| 45 | { |
||||
| 46 | return Webtrees::MODULES_DIR . trim($this->name(), '_') . '/resources/'; |
||||
| 47 | } |
||||
| 48 | |||||
| 49 | /** |
||||
| 50 | * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleAuthorName() |
||||
| 51 | */ |
||||
| 52 | public function customModuleAuthorName(): string |
||||
| 53 | { |
||||
| 54 | return 'Jonathan Jaubart'; |
||||
| 55 | } |
||||
| 56 | |||||
| 57 | /** |
||||
| 58 | * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleSupportUrl() |
||||
| 59 | */ |
||||
| 60 | public function customModuleSupportUrl(): string |
||||
| 61 | { |
||||
| 62 | return 'https://github.com/jon48/webtrees-lib'; |
||||
| 63 | } |
||||
| 64 | |||||
| 65 | /** |
||||
| 66 | * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customTranslations() |
||||
| 67 | * |
||||
| 68 | * @return array<string, string> |
||||
| 69 | */ |
||||
| 70 | public function customTranslations(string $language): array |
||||
| 71 | { |
||||
| 72 | $translation_file = $this->resourcesFolder() . 'lang/' . $language . '/messages.php'; |
||||
| 73 | |||||
| 74 | try { |
||||
| 75 | $translation = new Translation($translation_file); |
||||
| 76 | return $translation->asArray(); |
||||
| 77 | } catch (\Exception $e) { |
||||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
Loading history...
|
|||||
| 78 | } |
||||
| 79 | |||||
| 80 | return []; |
||||
| 81 | } |
||||
| 82 | |||||
| 83 | /** |
||||
| 84 | * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes |
||||
| 85 | * |
||||
| 86 | * @param Map<\Aura\Router\Route> $router |
||||
| 87 | */ |
||||
| 88 | public function loadRoutes(Map $router): void |
||||
|
0 ignored issues
–
show
The parameter
$router is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 89 | { |
||||
| 90 | } |
||||
| 91 | |||||
| 92 | /** |
||||
| 93 | * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::moduleCssUrl |
||||
| 94 | */ |
||||
| 95 | public function moduleCssUrl(): string |
||||
| 96 | { |
||||
| 97 | /** @var ModuleThemeInterface $theme */ |
||||
| 98 | $theme = app(ModuleThemeInterface::class); |
||||
| 99 | $css_file = $this->resourcesFolder() . 'css/' . $theme->name() . '.min.css'; |
||||
| 100 | |||||
| 101 | if (file_exists($css_file)) { |
||||
| 102 | return $this->assetUrl('css/' . $theme->name() . '.min.css'); |
||||
| 103 | } else { |
||||
| 104 | return $this->assetUrl('css/default.min.css'); |
||||
| 105 | } |
||||
| 106 | } |
||||
| 107 | } |
||||
| 108 |