JsonFormat.php 377 B

1234567891011121314151617181920
  1. <?php
  2. /**
  3. * Json
  4. * Builds a JSON string from $this->items and return it to browser.
  5. */
  6. class JsonFormat extends FormatAbstract {
  7. public function stringify(){
  8. $items = $this->getItems();
  9. return json_encode($items, JSON_PRETTY_PRINT);
  10. }
  11. public function display(){
  12. $this
  13. ->setContentType('application/json')
  14. ->callContentType();
  15. return parent::display();
  16. }
  17. }