Completed
Push — master ( dcec83...25cbf2 )
by Antony
02:35
created

Dealer::getHooks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 55
Code Lines 43

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 1 Features 4
Metric Value
c 5
b 1
f 4
dl 0
loc 55
rs 9.7692
cc 1
eloc 43
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
* This class has been generated by TheliaStudio
4
* For more information, see https://github.com/thelia-modules/TheliaStudio
5
*/
6
7
namespace Dealer;
8
9
use Dealer\Model\DealerContactInfoQuery;
10
use Dealer\Model\DealerContactQuery;
11
use Dealer\Model\DealerContentQuery;
12
use Dealer\Model\DealerFolderQuery;
13
use Dealer\Model\DealerQuery;
14
use Dealer\Model\DealerShedulesQuery;
15
use Thelia\Core\Template\TemplateDefinition;
16
use Thelia\Module\BaseModule;
17
use Propel\Runtime\Connection\ConnectionInterface;
18
use Thelia\Install\Database;
19
20
/**
21
 * Class Dealer
22
 * @package Dealer
23
 */
24
class Dealer extends BaseModule
25
{
26
    const MESSAGE_DOMAIN = "dealer";
27
    const ROUTER = "router.dealer";
28
29
    public function postActivation(ConnectionInterface $con = null)
30
    {
31
        try {
32
            DealerQuery::create()->findOne();
33
            DealerContactInfoQuery::create()->findOne();
34
            DealerContactQuery::create()->findOne();
35
            DealerShedulesQuery::create()->findOne();
36
            DealerContentQuery::create()->findOne();
37
            DealerFolderQuery::create()->findOne();
38
        } catch (\Exception $e) {
39
            $database = new Database($con);
40
            $database->insertSql(null, [__DIR__ . "/Config/thelia.sql"]);
41
        }
42
    }
43
44
    /**
45
     * @inheritDoc
46
     */
47
    public function update($currentVersion, $newVersion, ConnectionInterface $con = null)
48
    {
49
       if($currentVersion == "2.0" && $currentVersion != $newVersion){
50
           $database = new Database($con);
51
           $database->insertSql(null, [__DIR__ . "/Setup/sql/update-2.0-to-2.1.sql"]);
52
           $database->insertSql(null, [__DIR__ . "/Setup/sql/update-2.1-to-2.1.2.sql"]);
53
           $database->insertSql(null, [__DIR__ . "/Setup/sql/update-2.1.4-to-2.2.sql"]);
54
       }
55
       if($currentVersion == "2.1" && $currentVersion != $newVersion){
56
           $database = new Database($con);
57
           $database->insertSql(null, [__DIR__ . "/Setup/sql/update-2.1-to-2.1.2.sql"]);
58
           $database->insertSql(null, [__DIR__ . "/Setup/sql/update-2.1.4-to-2.2.sql"]);
59
       }
60
       if($currentVersion == "2.1.4" && $currentVersion != $newVersion){
61
           $database = new Database($con);
62
           $database->insertSql(null, [__DIR__ . "/Setup/sql/update-2.1.4-to-2.2.sql"]);
63
       }
64
    }
65
66
67
    public function getHooks(){
68
        return [
69
            array(
70
                "type" => TemplateDefinition::BACK_OFFICE,
71
                "code" => "dealer.extra.content.edit",
72
                "title" => "Dealer Extra Content",
73
                "description" => [
74
                    "en_US" =>"Allow you to insert element in modules tab on Dealer edit page",
75
                    "fr_FR" =>"Permet l'ajout de contenu sur la partie module de l'edition",
76
                ],
77
                "active" => true,
78
            ),
79
            array(
80
                "type" => TemplateDefinition::BACK_OFFICE,
81
                "code" => "dealer.edit.js",
82
                "title" => "Dealer Extra Js",
83
                "description" => [
84
                    "en_US" =>"Allow you to insert js on Dealer edit page",
85
                    "fr_FR" =>"Permet l'ajout de js sur l'edition",
86
                ],
87
                "active" => true,
88
            ),
89
            array(
90
                "type" => TemplateDefinition::BACK_OFFICE,
91
                "code" => "dealer.additional",
92
                "title" => "Dealer Extra Tab",
93
                "description" => [
94
                    "en_US" =>"Allow you to insert a tab on Dealer edit page",
95
                    "fr_FR" =>"Permet l'ajout d'une page sur l'edition d'un point de vente",
96
                ],
97
                "active" => true,
98
                "block" => true,
99
            ),
100
            array(
101
                "type" => TemplateDefinition::BACK_OFFICE,
102
                "code" => "dealer.edit.nav.bar",
103
                "title" => "Dealer Edition NavBar Link",
104
                "description" => [
105
                    "en_US" =>"Allow you to insert link between arrow previous and next on edtion view",
106
                    "fr_FR" =>"Permet l'ajout d'un lien sur la page d'édition entre les liens suivant et précedent",
107
                ],
108
                "active" => true,
109
            ),
110
            array(
111
                "type" => TemplateDefinition::BACK_OFFICE,
112
                "code" => "dealer.associated.tabcontent",
113
                "title" => "Dealer Associated Nav Tab",
114
                "description" => [
115
                    "en_US" =>"Allow you to insert association content",
116
                    "fr_FR" =>"Permet l'ajout de contenu dans la table d'association",
117
                ],
118
                "active" => true,
119
            ),
120
        ];
121
    }
122
}
123