/** * Returns an instance of Request object * @return Request */ public static function getInstance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; }
public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new self(); } return self::$instance; }
/** * @return Response */ public static function getInstance() { if (!self::$instance instanceof Response) { self::$instance = new Response(); } return self::$instance; }
/** * получаем экземпляр объекта * необходим при испоьзовании HMVC * */ function getInstance($redirect_if_not_ajax = TRUE) { if (is_null(self::$instance)) { self::$instance = new Response($redirect_if_not_ajax); } return self::$instance; }
public function __construct() { parent::__construct(); $this->parent_nav_active = 'manage'; $this->child_nav_active = 'collect'; $this->grandchild_nav_active = 'collect'; $this->rsp = Response::instance(); }
/** * @static * @return Response */ public static function getInstance() { if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } return self::$instance; }
public function exec() { $class_name = 'Resource_' . str_replace('/', '_', $this->get_resource()); $class = new ReflectionClass($class_name); $resource = $class->newInstance($this); $class->getMethod('before')->invoke($resource); $class->getMethod($this->request_method)->invoke($resource); $class->getMethod('after')->invoke($resource); $response = Response::instance(); $response->set_body($resource->get_data()); return $response; }
public function __construct() { parent::__construct(); $this->parent_nav_active = 'manage'; $this->active_tag = isset($_GET['tag']) ? $_GET['tag'] : 'all'; $this->publish = isset($_GET['publish']) ? $_GET['publish'] : NULL; $this->active_rating = isset($_GET['rating']) ? $_GET['rating'] : 'all'; $this->active_range = isset($_GET['range']) ? $_GET['range'] : 'all'; $this->active_page = (isset($_GET['page']) and is_numeric($_GET['page'])) ? $_GET['page'] : 1; $this->testimonial_id = isset($_GET['id']) ? valid::id_key($_GET['id']) : NULL; # prep the ajax response $this->rsp = Response::instance(); }
public function change_password() { if (!$_POST) { die; } $old_pw = $_POST['old_pw']; $salt = $this->auth->find_salt($this->owner->password); $old_pw = $this->auth->hash_password($old_pw, $salt); $this->rsp = Response::instance(); if ($old_pw == $this->owner->password) { $this->owner->password = $_POST['new_pw']; $this->owner->save(); $this->rsp->status = 'success'; $this->rsp->msg = 'Password Changed!'; $this->rsp->send(); } $this->rsp->msg = 'Invalid Password!'; $this->rsp->send(); }
public function __construct() { parent::__construct(); $this->parent_nav_active = 'display'; $this->rsp = Response::instance(); }
<?php define('DS', DIRECTORY_SEPARATOR); define('APP_PATH', dirname(__FILE__) . DS); define('SYS_PATH', realpath(dirname(__FILE__) . DS . '..' . DS . 'system') . DS); define('RESOURCE_PATH', dirname(__FILE__) . DS . 'classes' . DS . 'resource' . DS); require SYS_PATH . 'classes' . DS . 'resty' . DS . 'core.php'; require SYS_PATH . 'classes' . DS . 'resty.php'; Resty::instance()->init(); try { Request::instance()->exec()->output(); } catch (Route_Exception $e) { Response::instance()->set_status(404)->set_body(array('error' => 'Resource Not Found', 'Request' => $_SERVER['REQUEST_URI']))->output(); }