Esempio n. 1
0
 /**
  * Encode input $array to JSON
  * 
  * @param array $array
  * @throws Exception
  */
 private function toJSON($array)
 {
     /*
      * JSON-P case
      */
     $pretty = isset($this->context->query['_pretty']) ? filter_var($this->context->query['_pretty'], FILTER_VALIDATE_BOOLEAN) : false;
     if (isset($this->context->query['callback'])) {
         return $this->context->query['callback'] . '(' . json_encode($array, $pretty) . ')';
     }
     return RestoUtil::json_format($array, $pretty);
 }
Esempio n. 2
0
 /**
  * Output product description as a GeoJSON Feature
  * 
  * @param boolean $pretty : true to return pretty print
  */
 public function toJSON($pretty = false)
 {
     return RestoUtil::json_format($this->toArray(true), $pretty);
 }
Esempio n. 3
0
 /**
  * Output collections descriptions as a JSON stream
  * 
  * @param boolean $pretty : true to return pretty print
  */
 public function toJSON($pretty)
 {
     $collections = array('synthesis' => array('name' => '*', 'osDescription' => isset($this->context->osDescription[$this->context->dictionary->language]) ? $this->context->osDescription[$this->context->dictionary->language] : $this->context->osDescription['en'], 'statistics' => $this->context->dbDriver->get(RestoDatabaseDriver::STATISTICS, array('collectionName' => null, 'facetFields' => $this->model->getFacetFields()))), 'collections' => array());
     foreach (array_keys($this->collections) as $key) {
         $collections['collections'][] = $this->collections[$key]->toArray(true);
     }
     return RestoUtil::json_format($collections, $pretty);
 }
Esempio n. 4
0
 /**
  * Return the cart as a JSON file
  * 
  * @param boolean $pretty
  */
 public function toJSON($pretty)
 {
     $informations = $this->generateItemsInformations();
     return RestoUtil::json_format(array('status' => 'success', 'message' => 'Order ' . $this->order['orderId'] . ' for user ' . $this->user->profile['email'], 'order' => array('orderId' => $this->order['orderId'], 'items' => $informations['items'], 'errors' => $informations['errors'])), $pretty);
 }
Esempio n. 5
0
 /**
  * Return the cart as a JSON file
  * 
  * @param boolean $pretty
  */
 public function toJSON($pretty)
 {
     return RestoUtil::json_format($this->getItems(), $pretty);
 }