-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsschreierAdditionalbadgesw5.php
executable file
·129 lines (109 loc) · 4.77 KB
/
sschreierAdditionalbadgesw5.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
namespace sschreierAdditionalbadgesw5;
use Shopware\Components\Plugin;
use Shopware\Components\Plugin\Context\InstallContext;
use Shopware\Components\Plugin\Context\ActivateContext;
use Shopware\Components\Plugin\Context\UninstallContext;
class sschreierAdditionalbadgesw5 extends Plugin {
public function install(InstallContext $installContext){
$this->createArticleAttribute();
}
public function activate(ActivateContext $activateContext){
$activateContext->scheduleClearCache(InstallContext::CACHE_LIST_ALL);
}
public function uninstall(UninstallContext $uninstallContext){
if($uninstallContext->keepUserData()){
return;
}
$this->removeArticleAttribute();
$uninstallContext->scheduleClearCache(InstallContext::CACHE_LIST_ALL);
}
private function createArticleAttribute(){
$attributeService = $this->container->get('shopware_attribute.crud_service');
$attributeService->update(
's_articles_attributes',
'attr_hasadditionalbadge',
'boolean',
[
'label' => 'Hat das zusätzliche Badge',
'supportText' => '',
'helpText' => 'Hat das zusätzliche Badge',
'translatable' => true,
'displayInBackend' => true,
'position' => 4,
'custom' => true
]
);
$attributeService->update(
's_articles_attributes',
'attr_textadditionalbadge',
'string',
[
'label' => 'Text des zusätzlichen Badges',
'supportText' => '',
'helpText' => 'Text des zusätzlichen Badges',
'translatable' => true,
'displayInBackend' => true,
'position' => 5,
'custom' => true
]
);
$attributeService->update(
's_articles_attributes',
'attr_backgroundcoloradditionalbadge',
'string',
[
'label' => 'Hintergrundfarbe des zusätzlichen Badges als Hexcode',
'supportText' => '',
'helpText' => 'Hintergrundfarbe des zusätzlichen Badges als Hexcode',
'translatable' => true,
'displayInBackend' => true,
'position' => 6,
'custom' => true
]
);
$attributeService->update(
's_articles_attributes',
'attr_fontcoloradditionalbadge',
'string',
[
'label' => 'Schriftfarbe des zusätzlichen Badges als Hexcode',
'supportText' => '',
'helpText' => 'Schriftfarbe des zusätzlichen Badges als Hexcode',
'translatable' => true,
'displayInBackend' => true,
'position' => 6,
'custom' => true
]
);
$metaDataCache = $this->container->get('models')->getConfiguration()->getMetadataCacheImpl();
$metaDataCache->deleteAll();
$this->container->get('models')->generateAttributeModels(
array(
's_articles_attributes'
)
);
}
private function removeArticleAttribute(){
$attributeService = $this->container->get('shopware_attribute.crud_service');
try {
$attributeService->delete('s_articles_attributes', 'attr_hasadditionalbadge');
} catch (\Exception $e) {}
try {
$attributeService->delete('s_articles_attributes', 'attr_textadditionalbadge');
} catch (\Exception $e) {}
try {
$attributeService->delete('s_articles_attributes', 'attr_backgroundcoloradditionalbadge');
} catch (\Exception $e) {}
try {
$attributeService->delete('s_articles_attributes', 'attr_fontcoloradditionalbadge');
} catch (\Exception $e) {}
$metaDataCache = $this->container->get('models')->getConfiguration()->getMetadataCacheImpl();
$metaDataCache->deleteAll();
$this->container->get('models')->generateAttributeModels(
array(
's_articles_attributes'
)
);
}
}