Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 45b2ce9

Browse files
authored
Added illustration; refs #46049 (#36)
* Added illustration; refs #46049 * Some fixes; refs #46049 * Fixed illustration; refs #46049
1 parent bd4e3a3 commit 45b2ce9

File tree

20 files changed

+684
-227
lines changed

20 files changed

+684
-227
lines changed

202/build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<property name="src-dir" value="${basedir}"/>
2424
<property name="TARGETNAME" value="axeptiocookies"/>
2525
<property name="TARGETBRANCH" value="${env.GIT_BRANCH}"/>
26-
<property name="TARGETVERSION" value="2.0.7"/>
26+
<property name="TARGETVERSION" value="2.0.8"/>
2727

2828
<target name="build" depends="build-common,package-zip,psvalidator"/>
2929

202/test/AxeptiocookiesAddon/Service/ConfigurationServiceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ protected function getEditConfigurationObject()
200200
]
201201
]
202202
))
203+
->setPaint(false)
204+
->setIllustration('test.png')
203205
->setModules([
204206
[
205207
'name' => 'ps_shoppingcart',

config/partials/service.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ services:
3434
- '@AxeptiocookiesAddon\Service\ModuleService'
3535
- '@AxeptiocookiesAddon\Validator\ConfigurationValidator'
3636
- '@AxeptiocookiesAddon\Service\HookService'
37+
- '@AxeptiocookiesAddon\Service\ImageService'
3738

3839
AxeptiocookiesAddon\Cache\ProjectCache:
3940
class: AxeptiocookiesAddon\Cache\ProjectCache
@@ -47,6 +48,7 @@ services:
4748
- '@AxeptiocookiesAddon\Service\ProjectService'
4849
- '@AxeptiocookiesAddon\Repository\ConfigurationRepository'
4950
- '@AxeptiocookiesAddon\Service\ModuleService'
51+
- '@AxeptiocookiesAddon\Service\ImageService'
5052

5153
AxeptiocookiesAddon\Service\CookieService:
5254
class: AxeptiocookiesAddon\Service\CookieService
@@ -56,4 +58,8 @@ services:
5658

5759
AxeptiocookiesAddon\API\Response\Factory\ResponseFactory:
5860
class: AxeptiocookiesAddon\API\Response\Factory\ResponseFactory
61+
public: true
62+
63+
AxeptiocookiesAddon\Service\ImageService:
64+
class: AxeptiocookiesAddon\Service\ImageService
5965
public: true

controllers/admin/AdminAxeptiocookiesConfiguration.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ protected function getJsVariables()
130130
'modules' => $this->l('Modules', $this->controller_name),
131131
'consentv2' => $this->l('Consent Mode V2', $this->controller_name),
132132
],
133+
'illustration' => $this->l('Illustration', $this->controller_name),
134+
'illustration_choose' => $this->l('Choose illustration...', $this->controller_name),
135+
'illustration_custom' => $this->l('I would like a
136+
personalised illustration', $this->controller_name),
137+
'no_illustration' => $this->l('I don\'t want an illustration', $this->controller_name),
138+
'paint' => $this->l('Activate the paint task', $this->controller_name),
133139
'project_title' => $this->l('Project ID', $this->controller_name),
134140
'configuration_title' => $this->l('Configuration', $this->controller_name),
135141
'shop_title' => $this->l('Shops', $this->controller_name),

controllers/admin/AdminAxeptiocookiesConfigurationAjax.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ public function displayAjaxEditConfiguration()
183183
->setMessage($configuration['message'])
184184
->setTitle($configuration['title'])
185185
->setSubtitle($configuration['subtitle'])
186+
->setHasIllustration(!empty($configuration['has_illustration']) && $configuration['has_illustration'] == 'true')
187+
->setPaint(!empty($configuration['paint']) && $configuration['paint'] == 'true')
188+
->setIllustration(!empty($configuration['illustration'])
189+
&& !empty($configuration['has_illustration'])
190+
&& $configuration['has_illustration'] == 'true' ? $configuration['illustration'] : null)
186191
->setIsConsentV2(!empty($configuration['is_consent_v2']) && $configuration['is_consent_v2'] == 'true')
187192
->setAnalyticsStorage(!empty($configuration['analytics_storage']) && $configuration['analytics_storage'] == 'true')
188193
->setAdStorage(!empty($configuration['ad_storage']) && $configuration['ad_storage'] == 'true')

src/Entity/AxeptioConfiguration.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ class AxeptioConfiguration extends \ObjectModel
8585
*/
8686
public $ad_personalization = false;
8787

88+
/**
89+
* @var bool
90+
*/
91+
public $paint = true;
92+
93+
/**
94+
* @var string|null
95+
*/
96+
public $illustration;
97+
8898
public function __construct($id = null, $id_lang = null, $id_shop = null, $translator = null)
8999
{
90100
parent::__construct($id, $id_lang, $id_shop, $translator);
@@ -152,6 +162,19 @@ public function __construct($id = null, $id_lang = null, $id_shop = null, $trans
152162
'required' => false,
153163
'validate' => 'isBool',
154164
],
165+
'paint' => [
166+
'type' => self::TYPE_BOOL,
167+
'required' => false,
168+
'validate' => 'isBool',
169+
'default' => '1',
170+
],
171+
'illustration' => [
172+
'type' => self::TYPE_STRING,
173+
'required' => false,
174+
'size' => 255,
175+
'validate' => 'isCleanHtml',
176+
'allow_null' => true,
177+
],
155178
],
156179
];
157180

@@ -171,6 +194,8 @@ public function toArray()
171194
'ad_storage' => $this->ad_storage,
172195
'ad_user_data' => $this->ad_user_data,
173196
'ad_personalization' => $this->ad_personalization,
197+
'paint' => $this->paint,
198+
'illustration' => $this->illustration,
174199
];
175200
}
176201
}

src/Model/EditConfigurationModel.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ class EditConfigurationModel implements \JsonSerializable
7373
*/
7474
protected $subtitle;
7575

76+
/**
77+
* @var string|null
78+
*/
79+
protected $illustration;
80+
7681
/**
7782
* @var bool
7883
*/
@@ -98,6 +103,16 @@ class EditConfigurationModel implements \JsonSerializable
98103
*/
99104
public $ad_personalization = false;
100105

106+
/**
107+
* @var bool
108+
*/
109+
public $has_illustration = false;
110+
111+
/**
112+
* @var bool
113+
*/
114+
public $paint = true;
115+
101116
/**
102117
* @var array
103118
*/
@@ -403,6 +418,66 @@ public function setAdPersonalization($ad_personalization)
403418
return $this;
404419
}
405420

421+
/**
422+
* @return string|null
423+
*/
424+
public function getIllustration()
425+
{
426+
return $this->illustration;
427+
}
428+
429+
/**
430+
* @param string|null $illustration
431+
*
432+
* @return EditConfigurationModel
433+
*/
434+
public function setIllustration($illustration)
435+
{
436+
$this->illustration = $illustration;
437+
438+
return $this;
439+
}
440+
441+
/**
442+
* @return bool
443+
*/
444+
public function hasIllustration()
445+
{
446+
return $this->has_illustration;
447+
}
448+
449+
/**
450+
* @param bool $has_illustration
451+
*
452+
* @return EditConfigurationModel
453+
*/
454+
public function setHasIllustration($has_illustration)
455+
{
456+
$this->has_illustration = $has_illustration;
457+
458+
return $this;
459+
}
460+
461+
/**
462+
* @return bool
463+
*/
464+
public function getPaint()
465+
{
466+
return $this->paint;
467+
}
468+
469+
/**
470+
* @param bool $paint
471+
*
472+
* @return EditConfigurationModel
473+
*/
474+
public function setPaint($paint)
475+
{
476+
$this->paint = $paint;
477+
478+
return $this;
479+
}
480+
406481
public function jsonSerialize()
407482
{
408483
return get_object_vars($this);

src/Model/Integration/StepModel.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class StepModel implements \JsonSerializable
6767
*/
6868
protected $subTitle = '';
6969

70+
/**
71+
* @var bool
72+
*/
73+
protected $disablePaint = false;
74+
7075
/**
7176
* @var array<VendorModel>
7277
*/
@@ -272,6 +277,26 @@ public function setVendors($vendors)
272277
return $this;
273278
}
274279

280+
/**
281+
* @return bool
282+
*/
283+
public function getDisablePaint()
284+
{
285+
return $this->disablePaint;
286+
}
287+
288+
/**
289+
* @param bool $disablePaint
290+
*
291+
* @return StepModel
292+
*/
293+
public function setDisablePaint($disablePaint)
294+
{
295+
$this->disablePaint = $disablePaint;
296+
297+
return $this;
298+
}
299+
275300
public static function __set_state($array)
276301
{
277302
$obj = new StepModel();
@@ -285,6 +310,7 @@ public static function __set_state($array)
285310
$obj->setSubTitle($array['subTitle']);
286311
$obj->setTitle($array['title']);
287312
$obj->setVendors($array['vendors']);
313+
$obj->setDisablePaint(isset($array['disablePaint']) && (bool) $array['disablePaint']);
288314

289315
return $obj;
290316
}
@@ -301,6 +327,7 @@ public function toArray()
301327
'showToggleAllSwitch' => $this->isShowToggleAllSwitch(),
302328
'subTitle' => $this->getSubTitle(),
303329
'title' => $this->getTitle(),
330+
'disablePaint' => $this->getDisablePaint(),
304331
'vendors' => array_map(function (VendorModel $vendorModel) {
305332
return $vendorModel->toArray();
306333
}, $this->getVendors()),

src/Service/ConfigurationService.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,33 @@ class ConfigurationService
5757
* @var HookService
5858
*/
5959
protected $hookService;
60+
/**
61+
* @var ImageService
62+
*/
63+
protected $imageService;
6064

6165
/**
6266
* @param ConfigurationRepository $configurationRepository
6367
* @param ProjectService $projectService
6468
* @param ModuleService $moduleService
6569
* @param ConfigurationValidator $configurationValidator
6670
* @param HookService $hookService
71+
* @param ImageService $imageService
6772
*/
6873
public function __construct(
6974
ConfigurationRepository $configurationRepository,
7075
ProjectService $projectService,
7176
ModuleService $moduleService,
7277
ConfigurationValidator $configurationValidator,
73-
HookService $hookService
78+
HookService $hookService,
79+
ImageService $imageService
7480
) {
7581
$this->configurationRepository = $configurationRepository;
7682
$this->projectService = $projectService;
7783
$this->moduleService = $moduleService;
7884
$this->configurationValidator = $configurationValidator;
7985
$this->hookService = $hookService;
86+
$this->imageService = $imageService;
8087
}
8188

8289
public function createConfiguration(CreateConfigurationModel $configurationModel)
@@ -122,6 +129,14 @@ public function editConfiguration(EditConfigurationModel $configurationModel)
122129
$configuration->message = $configurationModel->getMessage();
123130
$configuration->title = $configurationModel->getTitle();
124131
$configuration->subtitle = $configurationModel->getSubtitle();
132+
$configuration->paint = $configurationModel->getPaint();
133+
134+
if (!empty($configuration->illustration)) {
135+
$this->imageService->deleteImage($configuration->illustration);
136+
}
137+
if (!empty($configurationModel->getIllustration()) && $configurationModel->hasIllustration()) {
138+
$configuration->illustration = $this->imageService->saveImage($configurationModel->getIllustration());
139+
}
125140

126141
if ($configurationModel->getIsConsentV2()) {
127142
$configuration->is_consent_v2 = $configurationModel->getIsConsentV2();
@@ -243,6 +258,8 @@ public function getById($idObject)
243258
return $carry;
244259
});
245260

261+
$illustration = $this->imageService->getIllustration($moduleConfiguration);
262+
246263
return (new EditConfigurationModel())
247264
->setIdObject((int) $idObject)
248265
->setLanguage(\Language::getLanguage($moduleConfiguration->id_lang))
@@ -256,6 +273,9 @@ public function getById($idObject)
256273
}, $moduleConfiguration->getAssociatedShops()))
257274
->setModules($modules)
258275
->setProject($project)
276+
->setPaint((bool) $moduleConfiguration->paint)
277+
->setHasIllustration(!empty($illustration))
278+
->setIllustration($this->imageService->getIllustration($moduleConfiguration))
259279
->setIsConsentV2((bool) $moduleConfiguration->is_consent_v2)
260280
->setAnalyticsStorage((bool) $moduleConfiguration->analytics_storage)
261281
->setAdStorage((bool) $moduleConfiguration->ad_storage)

src/Service/HookService.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,30 @@ class HookService
6262
*/
6363
protected $moduleService;
6464

65+
/**
66+
* @var ImageService
67+
*/
68+
protected $imageService;
69+
6570
/**
6671
* @param ProjectCache $projectCache
6772
* @param ProjectService $projectService
6873
* @param ConfigurationRepository $configurationRepository
6974
* @param ModuleService $moduleService
75+
* @param ImageService $imageService
7076
*/
7177
public function __construct(
7278
ProjectCache $projectCache,
7379
ProjectService $projectService,
7480
ConfigurationRepository $configurationRepository,
75-
ModuleService $moduleService
81+
ModuleService $moduleService,
82+
ImageService $imageService
7683
) {
7784
$this->projectCache = $projectCache;
7885
$this->projectService = $projectService;
7986
$this->configurationRepository = $configurationRepository;
8087
$this->moduleService = $moduleService;
88+
$this->imageService = $imageService;
8189
}
8290

8391
public function getIntegrationModelFromContext()
@@ -127,7 +135,14 @@ public function getIntegrationModelFromContext()
127135
$stepModel->setTitle($axeptioConfiguration->title);
128136
$stepModel->setSubTitle($axeptioConfiguration->subtitle);
129137
$stepModel->setVendors($vendors);
130-
138+
$stepModel->setDisablePaint(empty($axeptioConfiguration->paint));
139+
$illustration = $this->imageService->getIllustration($axeptioConfiguration);
140+
if (!empty($illustration)) {
141+
$illustrationUrl = $this->imageService->getImageUrl($axeptioConfiguration->illustration, \Context::getContext()->shop->id);
142+
if (!empty($illustrationUrl)) {
143+
$stepModel->setImage($illustrationUrl);
144+
}
145+
}
131146
$integrationModel->setModuleStep($stepModel);
132147
}
133148
if (!$axeptioConfiguration->is_consent_v2) {

0 commit comments

Comments
 (0)