Files
piratepoet/lib/Router/Segments.php
Jonathan Labreuille 7370d19be3 Segment listing
- fixed duplicate entry in Robofile for editor styles
- added Segment menu
- added Segment listing
- added listing methods to Segment model
- fixed syntax in both Segment & Subscriber models (MAX LINE 80!!!)
2015-09-04 13:02:23 +02:00

45 lines
731 B
PHP

<?php
namespace MailPoet\Router;
use \MailPoet\Models\Segment;
use \MailPoet\Listing;
if(!defined('ABSPATH')) exit;
class Segments {
function __construct() {
}
function get($data = array()) {
$listing = new Listing\Handler(
\Model::factory('\MailPoet\Models\Segment'),
$data
);
wp_send_json($listing->get());
}
function getAll() {
$collection = Segment::find_array();
wp_send_json($collection);
}
function save($args) {
$model = Segment::create();
$model->hydrate($args);
$saved = $model->save();
if(!$saved) {
wp_send_json($model->getValidationErrors());
}
wp_send_json(true);
}
function update($args) {
}
function delete($id) {
}
}