Skip to content

Commit 33eed81

Browse files
authored
Avoid CustomerSaveManager\LegacyTrait methods and trigger deprecations (#340)
* Avoid CustomerSaveManager\LegacyTrait methods and trigger deprecations * Update phpstan-baseline.neon
1 parent 9bb79f6 commit 33eed81

File tree

3 files changed

+76
-38
lines changed

3 files changed

+76
-38
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,6 @@ parameters:
205205
count: 1
206206
path: src/SegmentBuilder/AgeSegmentBuilder.php
207207

208-
-
209-
message: "#^Call to an undefined method CustomerManagementFrameworkBundle\\\\CustomerSaveManager\\\\CustomerSaveManagerInterface\\:\\:getSegmentBuildingHookEnabled\\(\\)\\.$#"
210-
count: 1
211-
path: src/SegmentManager/SegmentBuilderExecutor/DefaultSegmentBuilderExecutor.php
212-
213-
-
214-
message: "#^Call to an undefined method CustomerManagementFrameworkBundle\\\\CustomerSaveManager\\\\CustomerSaveManagerInterface\\:\\:setSegmentBuildingHookEnabled\\(\\)\\.$#"
215-
count: 2
216-
path: src/SegmentManager/SegmentBuilderExecutor/DefaultSegmentBuilderExecutor.php
217-
218208
-
219209
message: "#^Call to an undefined method Knp\\\\Component\\\\Pager\\\\Pagination\\\\PaginationInterface\\:\\:getPaginationData\\(\\)\\.$#"
220210
count: 1

src/CustomerSaveManager/LegacyTrait.php

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,38 @@
1919

2020
/**
2121
* @property SaveOptions $saveOptions
22+
*
23+
* @deprecated
2224
*/
2325
trait LegacyTrait
2426
{
2527
/**
2628
* @return bool
27-
*
28-
* @deprecated
2929
*/
3030
public function getSegmentBuildingHookEnabled()
3131
{
32+
trigger_deprecation(
33+
'pimcore/customer-data-framework',
34+
'1.3.17',
35+
sprintf('%s is deprecated.', __METHOD__)
36+
);
37+
3238
return $this->saveOptions->isOnSaveSegmentBuildersEnabled();
3339
}
3440

3541
/**
3642
* @param bool $segmentBuildingHookEnabled
3743
*
3844
* @return $this
39-
*
40-
* @deprecated
4145
*/
4246
public function setSegmentBuildingHookEnabled($segmentBuildingHookEnabled)
4347
{
48+
trigger_deprecation(
49+
'pimcore/customer-data-framework',
50+
'1.3.17',
51+
sprintf('%s is deprecated.', __METHOD__)
52+
);
53+
4454
if ($segmentBuildingHookEnabled) {
4555
$this->saveOptions->enableOnSaveSegmentBuilders();
4656
} else {
@@ -52,23 +62,31 @@ public function setSegmentBuildingHookEnabled($segmentBuildingHookEnabled)
5262

5363
/**
5464
* @return bool
55-
*
56-
* @deprecated
5765
*/
5866
public function getCustomerSaveValidatorEnabled()
5967
{
68+
trigger_deprecation(
69+
'pimcore/customer-data-framework',
70+
'1.3.17',
71+
sprintf('%s is deprecated.', __METHOD__)
72+
);
73+
6074
return $this->saveOptions->isValidatorEnabled();
6175
}
6276

6377
/**
6478
* @param bool $customerSaveValidatorEnabled
6579
*
6680
* @return $this
67-
*
68-
* @deprecated
6981
*/
7082
public function setCustomerSaveValidatorEnabled($customerSaveValidatorEnabled)
7183
{
84+
trigger_deprecation(
85+
'pimcore/customer-data-framework',
86+
'1.3.17',
87+
sprintf('%s is deprecated.', __METHOD__)
88+
);
89+
7290
if ($customerSaveValidatorEnabled) {
7391
$this->saveOptions->enableValidator();
7492
} else {
@@ -80,23 +98,31 @@ public function setCustomerSaveValidatorEnabled($customerSaveValidatorEnabled)
8098

8199
/**
82100
* @return bool
83-
*
84-
* @deprecated
85101
*/
86102
public function isDisableSaveHandlers()
87103
{
104+
trigger_deprecation(
105+
'pimcore/customer-data-framework',
106+
'1.3.17',
107+
sprintf('%s is deprecated.', __METHOD__)
108+
);
109+
88110
return !$this->saveOptions->isSaveHandlersExecutionEnabled();
89111
}
90112

91113
/**
92114
* @param bool $disableSaveHandlers
93115
*
94116
* @return $this
95-
*
96-
* @deprecated
97117
*/
98118
public function setDisableSaveHandlers($disableSaveHandlers)
99119
{
120+
trigger_deprecation(
121+
'pimcore/customer-data-framework',
122+
'1.3.17',
123+
sprintf('%s is deprecated.', __METHOD__)
124+
);
125+
100126
if ($disableSaveHandlers) {
101127
$this->saveOptions->disableSaveHandlers();
102128
} else {
@@ -108,23 +134,31 @@ public function setDisableSaveHandlers($disableSaveHandlers)
108134

109135
/**
110136
* @return bool
111-
*
112-
* @deprecated
113137
*/
114138
public function isDisableDuplicateIndex()
115139
{
140+
trigger_deprecation(
141+
'pimcore/customer-data-framework',
142+
'1.3.17',
143+
sprintf('%s is deprecated.', __METHOD__)
144+
);
145+
116146
return !$this->saveOptions->isDuplicatesIndexEnabled();
117147
}
118148

119149
/**
120150
* @param bool $disableDuplicateIndex
121151
*
122152
* @return $this
123-
*
124-
* @deprecated
125153
*/
126154
public function setDisableDuplicateIndex($disableDuplicateIndex)
127155
{
156+
trigger_deprecation(
157+
'pimcore/customer-data-framework',
158+
'1.3.17',
159+
sprintf('%s is deprecated.', __METHOD__)
160+
);
161+
128162
if ($disableDuplicateIndex) {
129163
$this->saveOptions->disableDuplicatesIndex();
130164
} else {
@@ -136,23 +170,31 @@ public function setDisableDuplicateIndex($disableDuplicateIndex)
136170

137171
/**
138172
* @return bool
139-
*
140-
* @deprecated
141173
*/
142174
public function isDisableQueue()
143175
{
176+
trigger_deprecation(
177+
'pimcore/customer-data-framework',
178+
'1.3.17',
179+
sprintf('%s is deprecated.', __METHOD__)
180+
);
181+
144182
return !$this->saveOptions->isSegmentBuilderQueueEnabled();
145183
}
146184

147185
/**
148186
* @param bool $disableQueue
149187
*
150188
* @return $this
151-
*
152-
* @deprecated
153189
*/
154190
public function setDisableQueue($disableQueue)
155191
{
192+
trigger_deprecation(
193+
'pimcore/customer-data-framework',
194+
'1.3.17',
195+
sprintf('%s is deprecated.', __METHOD__)
196+
);
197+
156198
if ($disableQueue) {
157199
$this->saveOptions->disableSegmentBuilderQueue();
158200
} else {
@@ -167,14 +209,15 @@ public function setDisableQueue($disableQueue)
167209
* @param bool $disableVersions
168210
*
169211
* @return mixed
170-
*
171-
* @deprecated
172212
*/
173213
public function saveWithDisabledHooks(CustomerInterface $customer, $disableVersions = false)
174214
{
175-
/**
176-
* @var SaveOptions $options
177-
*/
215+
trigger_deprecation(
216+
'pimcore/customer-data-framework',
217+
'1.3.17',
218+
sprintf('%s is deprecated.', __METHOD__)
219+
);
220+
178221
$options = $this->getSaveOptions(true);
179222
$options
180223
->disableValidator()

src/SegmentManager/SegmentBuilderExecutor/DefaultSegmentBuilderExecutor.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ public function buildCalculatedSegments(
9797
$logger = $this->getLogger();
9898
$logger->notice('start segment building');
9999

100-
$backup = $this->customerSaveManager->getSegmentBuildingHookEnabled();
101-
$this->customerSaveManager->setSegmentBuildingHookEnabled(false);
100+
$saveOptions = $this->customerSaveManager->getSaveOptions();
101+
$backup = $saveOptions->isOnSaveSegmentBuildersEnabled();
102+
$saveOptions->disableOnSaveSegmentBuilders();
102103

103104
if (!is_null($segmentBuilderServiceId)) {
104105
$segmentBuilders = [\Pimcore::getContainer()->get($segmentBuilderServiceId)];
@@ -330,7 +331,11 @@ public function buildCalculatedSegments(
330331
$flushQueue($customerQueueRemoval);
331332
}
332333

333-
$this->customerSaveManager->setSegmentBuildingHookEnabled($backup);
334+
if ($backup) {
335+
$saveOptions->enableOnSaveSegmentBuilders();
336+
} else {
337+
$saveOptions->disableOnSaveSegmentBuilders();
338+
}
334339
}
335340

336341
protected function getIntOption(array $options, $option)

0 commit comments

Comments
 (0)