/** * @param string $basePath * @return Xinc_Api_Handler */ public static function getInstance($basePath = '/api') { if (!isset(Xinc_Api_Handler::$_instance)) { Xinc_Api_Handler::$_instance = new Xinc_Api_Handler($basePath); } return Xinc_Api_Handler::$_instance; }
/** * * @param Xinc_Plugin_Interface $plugin */ public function __construct(Xinc_Plugin_Interface $plugin) { parent::__construct($plugin); Xinc_Api_Handler::getInstance()->registerResponseFormat(new Xinc_Plugin_Repos_Api_Format_Json()); Xinc_Api_Handler::getInstance()->registerResponseFormat(new Xinc_Plugin_Repos_Api_Format_File()); Xinc_Api_Handler::getInstance()->registerResponseFormat(new Xinc_Plugin_Repos_Api_Format_Download()); }
public function view() { /** * Determine called Pathname */ $path = $this->getRequestPath(); if (strpos($path, $this->apiHandler->getBasePath()) === 0) { $this->apiHandler->processCall($path); return; } /** * Get the Widget to use for this Request from the Widget-Repository */ $widget = Xinc_Gui_Widget_Repository::getInstance()->getWidgetForPath($path); if (!$widget instanceof Xinc_Gui_Widget_Interface) { /** * Try Api Handler */ header('HTTP/1.0 404 Not Found'); die; } /** * Start session */ session_start(); if (!isset($_SESSION['Xinc_Gui_Handler'])) { $_SESSION['Xinc_Gui_Handler'] = 1; /** * Trigger the session_start event on the widget */ $widget->handleEvent(Xinc_Gui_Event::SESSION_START); } /** * trigger the page-load event */ try { $widget->handleEvent(Xinc_Gui_Event::PAGE_LOAD); } catch (Exception $e) { if ($widget->hasExceptionHandler()) { $widget->handleException($e); } else { $this->handleException($e); } } }