Example #1
0
 private function callOnAdapter(\Model_ServiceCustom $model, $method, $params = array())
 {
     $plugin = $model->plugin;
     if (empty($plugin)) {
         //error_log('Plugin is not used for this custom service');
         return null;
     }
     // check if plugin exists. If plugin does not exist, do not throw error. Simply add to log
     $file = sprintf('Plugin/%s/%s.php', $plugin, $plugin);
     if (APPLICATION_ENV != 'testing' && !file_exists(BF_PATH_LIBRARY . DIRECTORY_SEPARATOR . $file)) {
         $e = new \Fuse_Exception('Plugin class file :file was not found', array(':file' => $file), 3124);
         if (BF_DEBUG) {
             error_log($e->getMessage());
         }
         return null;
     }
     require_once $file;
     $config = $this->di['tools']->decodeJ($model->plugin_config);
     $adapter = new $plugin($config);
     if (!method_exists($adapter, $method)) {
         throw new \Fuse_Exception('Plugin :plugin does not support action :action', array(':plugin' => $plugin, ':action' => $method), 3125);
     }
     $orderService = $this->di['mod_service']('order');
     $order = $orderService->getServiceOrder($model);
     $order_data = $orderService->toApiArray($order);
     $data = $this->toApiArray($model);
     return $adapter->{$method}($data, $order_data, $params);
 }
 public function __construct($uri = "", $code = 0)
 {
     parent::__construct('You need to login in order to view this :url page', array(':url' => $uri), $code);
 }