1
|
|
|
<?php |
2
|
|
|
/*************************************************************************************/ |
3
|
|
|
/* This file is part of the module AttributeType */ |
4
|
|
|
/* */ |
5
|
|
|
/* Copyright (c) OpenStudio */ |
6
|
|
|
/* email : [email protected] */ |
7
|
|
|
/* web : http://www.thelia.net */ |
8
|
|
|
/* */ |
9
|
|
|
/* For the full copyright and license information, please view the LICENSE.txt */ |
10
|
|
|
/* file that was distributed with this source code. */ |
11
|
|
|
/*************************************************************************************/ |
12
|
|
|
|
13
|
|
|
namespace AttributeType; |
14
|
|
|
|
15
|
|
|
use Propel\Runtime\Connection\ConnectionInterface; |
16
|
|
|
use Symfony\Component\Finder\Finder; |
17
|
|
|
use Thelia\Core\Template\TemplateDefinition; |
18
|
|
|
use Thelia\Module\BaseModule; |
19
|
|
|
use Thelia\Install\Database; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class AttributeType |
23
|
|
|
* @package AttributeType |
24
|
|
|
* @author Gilles Bourgeat <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class AttributeType extends BaseModule |
27
|
|
|
{ |
28
|
|
|
const MODULE_DOMAIN = "attributetype"; |
29
|
|
|
|
30
|
|
|
const RESERVED_SLUG = 'id,attribute_id,id_translater,locale,title,chapo,description,postscriptum,position'; |
31
|
|
|
|
32
|
|
|
const ATTRIBUTE_TYPE_AV_IMAGE_FOLDER = 'attribute_type_av_images'; |
33
|
|
|
|
34
|
|
|
/** @var string */ |
35
|
|
|
const UPDATE_PATH = __DIR__ . DS . 'Config' . DS . 'update'; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param ConnectionInterface $con |
39
|
|
|
*/ |
40
|
|
|
public function postActivation(ConnectionInterface $con = null) |
41
|
|
|
{ |
42
|
|
|
if (!$this->getConfigValue('is_initialized', false)) { |
43
|
|
|
$database = new Database($con); |
44
|
|
|
$database->insertSql(null, [__DIR__ . "/Config/thelia.sql", __DIR__ . "/Config/insert.sql"]); |
45
|
|
|
$this->setConfigValue('is_initialized', true); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param $currentVersion |
51
|
|
|
* @param $newVersion |
52
|
|
|
* @param ConnectionInterface|null $con |
53
|
|
|
*/ |
54
|
|
|
public function update($currentVersion, $newVersion, ConnectionInterface $con = null) |
55
|
|
|
{ |
56
|
|
|
$finder = (new Finder())->files()->name('#.*?\.sql#')->sortByName()->in(self::UPDATE_PATH); |
57
|
|
|
if ($finder->count() === 0) { |
58
|
|
|
return; |
59
|
|
|
} |
60
|
|
|
$database = new Database($con); |
61
|
|
|
/** @var \Symfony\Component\Finder\SplFileInfo $updateSQLFile */ |
62
|
|
|
foreach ($finder as $updateSQLFile) { |
63
|
|
|
if (version_compare($currentVersion, str_replace('.sql', '', $updateSQLFile->getFilename()), '<')) { |
64
|
|
|
$database->insertSql(null, [$updateSQLFile->getPathname()]); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return array |
71
|
|
|
*/ |
72
|
|
|
public function getHooks() |
73
|
|
|
{ |
74
|
|
|
return array( |
75
|
|
|
array( |
76
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
77
|
|
|
"code" => "attribute-type.form-top", |
78
|
|
|
"title" => array( |
79
|
|
|
"fr_FR" => "Module Attribute Type, form haut", |
80
|
|
|
"en_US" => "Module Attribute Type, form top", |
81
|
|
|
), |
82
|
|
|
"description" => array( |
83
|
|
|
"fr_FR" => "En haut du formulaire de création et de mise à jour", |
84
|
|
|
"en_US" => "Top of creation form and update", |
85
|
|
|
), |
86
|
|
|
"active" => true |
87
|
|
|
), |
88
|
|
|
array( |
89
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
90
|
|
|
"code" => "attribute-type.form-bottom", |
91
|
|
|
"title" => array( |
92
|
|
|
"fr_FR" => "Module Attribute Type, form bas", |
93
|
|
|
"en_US" => "Module Attribute Type, form bottom", |
94
|
|
|
), |
95
|
|
|
"description" => array( |
96
|
|
|
"fr_FR" => "En bas du formulaire de création et de mise à jour", |
97
|
|
|
"en_US" => "Top of creation form and update", |
98
|
|
|
), |
99
|
|
|
"active" => true |
100
|
|
|
), |
101
|
|
|
array( |
102
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
103
|
|
|
"code" => "attribute-type.configuration-top", |
104
|
|
|
"title" => array( |
105
|
|
|
"fr_FR" => "Module Attribute Type, configuration haut", |
106
|
|
|
"en_US" => "Module Attribute Type, configuration top", |
107
|
|
|
), |
108
|
|
|
"description" => array( |
109
|
|
|
"fr_FR" => "En haut du la page de configuration du module", |
110
|
|
|
"en_US" => "At the top of the module's configuration page", |
111
|
|
|
), |
112
|
|
|
"active" => true |
113
|
|
|
), |
114
|
|
|
array( |
115
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
116
|
|
|
"code" => "attribute-type.configuration-bottom", |
117
|
|
|
"title" => array( |
118
|
|
|
"fr_FR" => "Module Attribute Type, configuration bas", |
119
|
|
|
"en_US" => "Module Attribute Type, configuration bottom", |
120
|
|
|
), |
121
|
|
|
"description" => array( |
122
|
|
|
"fr_FR" => "En bas du la page de configuration du module", |
123
|
|
|
"en_US" => "At the bottom of the module's configuration page", |
124
|
|
|
), |
125
|
|
|
"active" => true |
126
|
|
|
), |
127
|
|
|
array( |
128
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
129
|
|
|
"code" => "attribute-type.list-action", |
130
|
|
|
"title" => array( |
131
|
|
|
"fr_FR" => "Module Attribute Type, liste des actiona", |
132
|
|
|
"en_US" => "Module Attribute Type, list action", |
133
|
|
|
), |
134
|
|
|
"description" => array( |
135
|
|
|
"fr_FR" => "Action de la liste des types de déclinaisons", |
136
|
|
|
"en_US" => "Action from the list of attributes types", |
137
|
|
|
), |
138
|
|
|
"active" => true |
139
|
|
|
), |
140
|
|
|
array( |
141
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
142
|
|
|
"code" => "attribute-type.list-action", |
143
|
|
|
"title" => array( |
144
|
|
|
"fr_FR" => "Module Attribute Type, list action", |
145
|
|
|
"en_US" => "Module Attribute Type, list action", |
146
|
|
|
), |
147
|
|
|
"description" => array( |
148
|
|
|
"fr_FR" => "Action de la liste des dates", |
149
|
|
|
"en_US" => "Action from the list of dates", |
150
|
|
|
), |
151
|
|
|
"active" => true |
152
|
|
|
), |
153
|
|
|
array( |
154
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
155
|
|
|
"code" => "attribute-type.configuration-js", |
156
|
|
|
"title" => array( |
157
|
|
|
"fr_FR" => "Module Attribute Type, configuration js", |
158
|
|
|
"en_US" => "Module Attribute Type, configuration js", |
159
|
|
|
), |
160
|
|
|
"description" => array( |
161
|
|
|
"fr_FR" => "JS la page de configuration du module", |
162
|
|
|
"en_US" => "JS of the module's configuration page", |
163
|
|
|
), |
164
|
|
|
"active" => true |
165
|
|
|
) |
166
|
|
|
); |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
|