Migration fix + removed model instantiation in Listing handler
This commit is contained in:
@@ -121,16 +121,16 @@ define(
|
||||
|
||||
var status = '';
|
||||
|
||||
switch(parseInt(subscriber.status, 10)) {
|
||||
case 1:
|
||||
switch(subscriber.status) {
|
||||
case 'subscribed':
|
||||
status = 'Subscribed';
|
||||
break;
|
||||
|
||||
case 0:
|
||||
case 'unconfirmed':
|
||||
status = 'Unconfirmed';
|
||||
break;
|
||||
|
||||
case -1:
|
||||
case 'unsubscribed':
|
||||
status = 'Unsubscribed';
|
||||
break;
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ class Migrator {
|
||||
'status varchar(12) NOT NULL DEFAULT "unconfirmed",',
|
||||
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
||||
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
||||
'PRIMARY KEY (id),',
|
||||
'PRIMARY KEY (id),',
|
||||
'UNIQUE KEY email (email)'
|
||||
);
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
@@ -60,7 +60,7 @@ class Migrator {
|
||||
'value varchar(255) NOT NULL,',
|
||||
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
||||
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
||||
'PRIMARY KEY (id),',
|
||||
'PRIMARY KEY (id),',
|
||||
'UNIQUE KEY name (name)'
|
||||
);
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
@@ -73,7 +73,7 @@ class Migrator {
|
||||
'body longtext,',
|
||||
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
||||
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
||||
'PRIMARY KEY (id)'
|
||||
'PRIMARY KEY (id)'
|
||||
);
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ class Handler {
|
||||
private $model = null;
|
||||
|
||||
function __construct($model, $data = array()) {
|
||||
$this->model = $this->getModel($model);
|
||||
$this->model = $model;
|
||||
$this->data = array(
|
||||
// pagination
|
||||
'offset' => (isset($data['offset']) ? (int)$data['offset'] : 0),
|
||||
@@ -28,10 +28,6 @@ class Handler {
|
||||
$this->setGroup();
|
||||
}
|
||||
|
||||
private function getModel($model) {
|
||||
return \Model::factory('\MailPoet\Models\\'.$model);
|
||||
}
|
||||
|
||||
private function setSearch() {
|
||||
if($this->data['search'] === null) {
|
||||
return;
|
||||
|
@@ -12,7 +12,10 @@ class Newsletters {
|
||||
}
|
||||
|
||||
function get($data = array()) {
|
||||
$listing = new Listing\Handler('Newsletter', $data);
|
||||
$listing = new Listing\Handler(
|
||||
\Model::factory('\MailPoet\Models\Newsletter'),
|
||||
$data
|
||||
);
|
||||
wp_send_json($listing->get());
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,10 @@ class Subscribers {
|
||||
}
|
||||
|
||||
function get($data = array()) {
|
||||
$listing = new Listing\Handler('Subscriber', $data);
|
||||
$listing = new Listing\Handler(
|
||||
\Model::factory('\MailPoet\Models\Subscriber'),
|
||||
$data
|
||||
);
|
||||
wp_send_json($listing->get());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user