Completed
Push — feature/code-analysis ( f93e28...a26fec )
by Jonathan
04:01
created

HooksModule::getTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * webtrees-lib: MyArtJaub library for webtrees
4
 *
5
 * @package MyArtJaub\Webtrees
6
 * @subpackage Hooks
7
 * @author Jonathan Jaubart <[email protected]>
8
 * @copyright Copyright (c) 2011-2016, Jonathan Jaubart
9
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3
10
 */
11
namespace MyArtJaub\Webtrees\Module;
12
13
use Fisharebest\Webtrees\Module\AbstractModule;
14
use Fisharebest\Webtrees\I18N;
15
use Fisharebest\Webtrees\Module\ModuleConfigInterface;
16
use Fisharebest\Webtrees\Database;
17
18
/**
19
 * Hooks Module.
20
 */
21
class HooksModule extends AbstractModule implements ModuleConfigInterface, DependentInterface {
22
    // How to update the database schema for this module
23
    const SCHEMA_TARGET_VERSION   = 1;
24
    const SCHEMA_SETTING_NAME     = 'MAJ_HOOKS_SCHEMA_VERSION';
25
    const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\Hooks\Schema';
26
    
27
    /** @var string For custom modules - link for support, upgrades, etc. */
28
    const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib';
29
    
30
    /**
31
     * {@inhericDoc}
32
     */
33
    public function getTitle() {
34
        return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks');
35
    }
36
    
37
    /**
38
     * {@inhericDoc}
39
     */
40
    public function getDescription() {
41
        return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.');
42
    }
43
    
44
    /**
45
     * {@inhericDoc}
46
     */
47
    public function modAction($mod_action) {
48
        Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
49
        
50
        \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action);
51
    }
52
    
53
    /**
54
     * {@inhericDoc}
55
     * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
56
     */
57
    public function getConfigLink() {
58
        Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
59
        
60
        return 'module.php?mod=' . $this->getName() . '&amp;mod_action=AdminConfig';
61
    }
62
    
63
    /**
64
     * {@inheritDoc}
65
     * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites()
66
     */
67
    public function validatePrerequisites() {
68
        try {
69
            Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
70
            return true;
71
        }
72
        catch (\Exception $ex) { }
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
73
        return false;
74
    }
75
    
76
77
}
78