示例#1
0
 /**
  * Return an instance of the Widget Repository
  *
  * @return Xinc_Api_Module_Repository
  */
 public static function getInstance()
 {
     if (!Xinc_Api_Module_Repository::$_instance) {
         Xinc_Api_Module_Repository::$_instance = new Xinc_Api_Module_Repository();
     }
     return Xinc_Api_Module_Repository::$_instance;
 }
示例#2
0
 public function registerPluginClass($class)
 {
     if (!class_exists($class)) {
         throw new ClassLoaderException($class);
     }
     $plugin = new $class();
     if (!$plugin instanceof PluginInterface) {
         throw new TypeMismatch(get_class($plugin), '\\Xinc\\Core\\Plugin\\PluginInterface');
     }
     $plugin->setConfig($this->config);
     $this->pluginRegistry->registerPlugin($plugin);
     $this->taskRegistry->registerTasks($plugin->getTaskDefinitions());
     $this->widgetRegistry->registerWidgets($plugin->getGuiWidgets());
     return;
     $apiModules = $plugin->getApiModules();
     foreach ($apiModules as $apiMod) {
         Xinc_Api_Module_Repository::getInstance()->registerModule($apiMod);
     }
 }
示例#3
0
 /**
  * Enter description here...
  *
  * @param Xinc_Plugin_Interface $plugin
  *
  * @return boolean
  * @throws Xinc_Plugin_Task_Exception
  */
 public function registerPlugin(Xinc_Plugin_Interface $plugin)
 {
     $tasks = $plugin->getTaskDefinitions();
     foreach ($tasks as $task) {
     }
     $widgets = $plugin->getGuiWidgets();
     foreach ($widgets as $widget) {
         Xinc_Gui_Widget_Repository::getInstance()->registerWidget($widget);
     }
     $apiModules = $plugin->getApiModules();
     foreach ($apiModules as $apiMod) {
         Xinc_Api_Module_Repository::getInstance()->registerModule($apiMod);
     }
     $this->plugins[] = $plugin;
 }
示例#4
0
 /**
  * Processes the call to a specific api url
  *
  * @param String $path
  */
 public function processCall($path)
 {
     /**
      * Matching pattern /$this->_basePath/$modulename/$methodname/$format/
      */
     preg_match('/\\' . $this->_basePath . '\\/(.*?)\\/(.*?)\\/(.*?)\\/.*/', $path, $matches);
     if (count($matches) < 4) {
         die('404');
     }
     $moduleName = $matches[1];
     $methodName = $matches[2];
     $formatName = $matches[3];
     if (!isset($this->_responseFormats[$formatName])) {
         die('UNKNOWN FORMAT: ' . $formatName);
     } else {
         $format = $this->_responseFormats[$formatName];
     }
     $module = Xinc_Api_Module_Repository::getInstance()->getModuleByNameAndMethod($moduleName, $methodName);
     if ($module != null) {
         $res = $module->processCall($methodName, $_REQUEST);
         echo $format->generate($res);
     }
 }