Newsletters router.
This commit is contained in:
35
lib/Router/Newsletters.php
Normal file
35
lib/Router/Newsletters.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
namespace MailPoet\Router;
|
||||||
|
use \MailPoet\Models\Newsletter;
|
||||||
|
|
||||||
|
if(!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
|
class Newsletters {
|
||||||
|
function __construct() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function get() {
|
||||||
|
$collection = Newsletter::find_array();
|
||||||
|
wp_send_json($collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
function save($args) {
|
||||||
|
$model = Newsletter::create();
|
||||||
|
$model->hydrate($args);
|
||||||
|
$saved = $model->save();
|
||||||
|
|
||||||
|
if(!$saved) {
|
||||||
|
wp_send_json($model->getValidationErrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
wp_send_json(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function update($args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete($id) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user