json output

This commit is contained in:
arzynik 2012-06-26 11:55:27 -07:00
parent 9022c04c90
commit 0aabc58a61
4 changed files with 40 additions and 5 deletions

View File

@ -4,12 +4,13 @@ class Controller_api_community extends Crunchbutton_Controller_Rest {
public function init() {
switch ($this->method()) {
case 'get':
$out = Community::o(1)->exports();
print_r($out); exit;
echo json_encode($out);
$out = Community::o(c::getPagePiece(2));
if ($out->id_community) {
echo $out->json();
} else {
echo json_encode(['error' => 'invalid object']);
}
break;
}
}
}

View File

@ -0,0 +1,16 @@
<?php
class Controller_api_restaurant extends Crunchbutton_Controller_Rest {
public function init() {
switch ($this->method()) {
case 'get':
$out = Restaurant::o(c::getPagePiece(2));
if ($out->id_restaurant) {
echo $out->json();
} else {
echo json_encode(['error' => 'invalid object']);
}
break;
}
}
}

View File

@ -36,6 +36,13 @@ class Crunchbutton_Restaurant extends Cana_Table {
}
return $this->_hours;
}
public function notification() {
if (!isset($this->_notification)) {
$this->_notification = Notification::q('select * from notification where id_notification="'.$this->id_notification.'"');
}
return $this->_notification;
}
public function exports() {
$out = $this->properties();

View File

@ -0,0 +1,11 @@
<?php
class Crunchbutton_Notification extends Cana_Table {
public function __construct($id = null) {
parent::__construct();
$this
->table('notification')
->idVar('id_notification')
->load($id);
}
}