Skip to content

Commit 9eb0547

Browse files
committed
always calling item pushed on stale handler
1 parent e28fdd4 commit 9eb0547

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/Commands/PushStaleToCyclopsCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ abstract class PushStaleToCyclopsCommand extends PushStateToCyclopsCommand
99
final function executeUseCase()
1010
{
1111
$pushUseCase = new PushStaleToCyclopsUseCase($this->getService());
12-
$pushUseCase->execute($this->getList(), $this->onCustomerCreated());
12+
$pushUseCase->execute($this->getList(), $this->getCustomerPushedHandler());
1313
}
1414

15-
abstract protected function onCustomerCreated(): callable;
15+
abstract protected function getCustomerPushedHandler(): callable;
1616
}

src/UseCases/PushStaleToCyclopsUseCase.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,18 @@ public function __construct(CyclopsService $cyclopsService)
1818
$this->cyclopsService = $cyclopsService;
1919
}
2020

21-
public function execute(CyclopsCustomerListEntity $list, callable $onCustomerCreated = null)
21+
public function execute(CyclopsCustomerListEntity $list, callable $onItemPushed)
2222
{
2323
foreach ($list->items as $item) {
2424
try {
2525
$this->cyclopsService->setBrandOptInStatus($item);
26-
27-
if ($onCustomerCreated !== null) {
28-
$onCustomerCreated($item);
29-
}
26+
$onItemPushed($item, false);
3027
} catch (CustomerNotFoundException $exception) {
3128
$customer = $this->cyclopsService->loadCustomer($item->identity);
3229
$customer->brandOptIn = $item->brandOptIn;
3330
$this->cyclopsService->setBrandOptInStatus($customer);
3431

35-
if ($onCustomerCreated !== null) {
36-
$onCustomerCreated($customer);
37-
}
32+
$onItemPushed($customer, true);
3833
}
3934
}
4035
}

0 commit comments

Comments
 (0)