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

@ -18,12 +18,19 @@ class Forms extends APIEndpoint {
/** @var Listing\BulkActionController */
private $bulk_action;
/** @var Listing\Handler */
private $listing_handler;
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_FORMS
);
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()) {
@ -39,8 +46,7 @@ class Forms extends APIEndpoint {
}
function listing($data = array()) {
$listing = new Listing\Handler();
$listing_data = $listing->get('\MailPoet\Models\Form', $data);
$listing_data = $this->listing_handler->get('\MailPoet\Models\Form', $data);
$data = array();
foreach($listing_data['items'] as $form) {