Refactor WP Users segment controller to injectable service
[MAILPOET-3141]
This commit is contained in:
committed by
Veljko V
parent
75e7012fb6
commit
645f888186
@@ -34,18 +34,23 @@ class Segments extends APIEndpoint {
|
||||
/** @var WooCommerce */
|
||||
private $wooCommerceSync;
|
||||
|
||||
/** @var WP */
|
||||
private $wpSegment;
|
||||
|
||||
public function __construct(
|
||||
Listing\BulkActionController $bulkAction,
|
||||
Listing\Handler $listingHandler,
|
||||
SegmentsRepository $segmentsRepository,
|
||||
SegmentsResponseBuilder $segmentsResponseBuilder,
|
||||
WooCommerce $wooCommerce
|
||||
WooCommerce $wooCommerce,
|
||||
WP $wpSegment
|
||||
) {
|
||||
$this->bulkAction = $bulkAction;
|
||||
$this->listingHandler = $listingHandler;
|
||||
$this->wooCommerceSync = $wooCommerce;
|
||||
$this->segmentsRepository = $segmentsRepository;
|
||||
$this->segmentsResponseBuilder = $segmentsResponseBuilder;
|
||||
$this->wpSegment = $wpSegment;
|
||||
}
|
||||
|
||||
public function get($data = []) {
|
||||
@@ -179,7 +184,7 @@ class Segments extends APIEndpoint {
|
||||
if ($data['type'] === Segment::TYPE_WC_USERS) {
|
||||
$this->wooCommerceSync->synchronizeCustomers();
|
||||
} else {
|
||||
WP::synchronizeUsers();
|
||||
$this->wpSegment->synchronizeUsers();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->errorResponse([
|
||||
|
Reference in New Issue
Block a user