Advertisement
fabi0

Untitled

Jun 8th, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  * To change this license header, choose License Headers in Project Properties.
  5.  * To change this template file, choose Tools | Templates
  6.  * and open the template in the editor.
  7.  */
  8.  
  9. /**
  10.  * Description of Json
  11.  *
  12.  * @author fabi0
  13.  */
  14.  
  15. namespace Controllers;
  16.  
  17. class Json {
  18.  
  19.     protected $_databaseInstance;
  20.  
  21.     public function __construct() {
  22.         $this->_databaseInstance = new \Models\Database(\Models\Config::mysql_host, \Models\Config::mysql_dbName, \Models\Config::mysql_username, \Models\Config::mysql_password);
  23.         $sess = new \Models\Sessions($this->_databaseInstance);
  24.         $sess->start_session(\Models\Config::cookie_session_name, false);
  25.         header('Content-Type: application/json');
  26.     }
  27.  
  28.     public function get($method = '') {
  29.         if (method_exists($this, $method)) {
  30.             echo json_encode($this->{$method}());
  31.         } else {
  32.             echo "Method not found";
  33.         }
  34.     }
  35.  
  36.     private function category() {
  37.         $category = new \Models\Category($this->_databaseInstance);
  38.         return $category->getCategoryTree();
  39.     }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement