Пример #1
0
 /**
  * 
  * Constructor
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     //Load the service controller
     $service = JRequest::getString('service', null);
     $doTask = JRequest::getString('do', null);
     if (empty($service)) {
         throw new Exception(_('undefined service'));
     }
     //Require service Controller
     $this->_serviceController =& TuiyoLoader::plugin((string) $service, true);
     $this->_serviceView =& $this->getView("services", "html");
     //Check that the service has the requested method and register call!
     if (!empty($doTask) && method_exists($this->_serviceController, $doTask)) {
         //echo "method exists";
         $this->_serviceController->{$doTask}();
         //call_user_func_array(array($this->_serviceController, $doTask) );
         return;
     }
 }
Пример #2
0
 /**
  * TuiyoLoader::plugin()
  * Loads a plugin/service controller
  * @param mixed $pluginName
  * @param bool $createInstance
  * @param mixed $parameters
  * @return
  */
 public function plugin($pluginName, $createInstance = false, $parmaeters = null)
 {
     $pluginName = strtolower($pluginName);
     $fileName = (string) $pluginName . ".controller";
     TuiyoLoader::import($fileName, 'plugin');
     if ($createInstance) {
         $pluginClass = ucfirst($pluginName) . 'ServiceController';
         if (in_array($pluginClass, self::$_stored["plugins"])) {
             $object = self::$_stored["plugins"][$pluginClass];
             if (is_object($object)) {
                 return $object;
             } else {
                 unset(self::$_stored["plugins"][$pluginClass]);
                 TuiyoLoader::plugin($pluginName, $createInstance, $parmaeters);
             }
         }
         $plugin = new $pluginClass($parmaeters);
         self::$_stored["plugins"][$pluginClass] =& $plugin;
         return $plugin;
     }
 }