Inject Listing Handler and Segments Subscriber Listing using DI

[MAILPOET-1689]
This commit is contained in:
Rostislav Wolny
2018-12-12 19:22:32 +01:00
parent a69ae0eea7
commit 66a05e1b19
8 changed files with 77 additions and 32 deletions

View File

@@ -30,12 +30,19 @@ class Newsletters extends APIEndpoint {
/** @var Listing\BulkActionController */
private $bulk_action;
/** @var Listing\Handler */
private $listing_handler;
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_EMAILS
);
function __construct(Listing\BulkActionController $bulk_action) {
function __construct(
Listing\BulkActionController $bulk_action,
Listing\Handler $listing_handler
) {
$this->bulk_action = $bulk_action;
$this->listing_handler = $listing_handler;
}
function get($data = array()) {
@@ -383,8 +390,7 @@ class Newsletters extends APIEndpoint {
}
function listing($data = array()) {
$listing = new Listing\Handler();
$listing_data = $listing->get('\MailPoet\Models\Newsletter', $data);
$listing_data = $this->listing_handler->get('\MailPoet\Models\Newsletter', $data);
$data = array();
foreach($listing_data['items'] as $newsletter) {