예제 #1
0
 /**
  * Initialize the list of plugins
  */
 private function initPlugins()
 {
     // perform a BAO query to select all active match plugins and insert instances for them into
     //    the matchers array by weight, then ksort descending
     $this->plugins = array();
     $matcher_type_id = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.plugin_classes', 'match');
     $params = array('version' => 3, 'plugin_type_id' => $matcher_type_id, 'enabled' => 1);
     $result = civicrm_api('BankingPluginInstance', 'get', $params);
     if (isset($result['is_error']) && $result['is_error']) {
         CRM_Core_Session::setStatus(ts("Error while trying to query database for matcher plugins!"), ts('No processors'), 'alert');
     } else {
         foreach ($result['values'] as $instance) {
             $pi_bao = new CRM_Banking_BAO_PluginInstance();
             $pi_bao->get('id', $instance['id']);
             // add to array wrt the weight
             if (!isset($this->plugins[$pi_bao->weight])) {
                 $this->plugins[$pi_bao->weight] = array();
             }
             array_push($this->plugins[$pi_bao->weight], $pi_bao->getInstance());
         }
     }
     // sort array by weight
     ksort($this->plugins);
 }
 /**
  * Upon loading a BTX from database, restore suggestions as they were
  * stored in JSON format 
  * 
  * TODO: move the restore to an instance method of Suggestion, thus no longer
  * expising the structure of the Suggestion here
  */
 private function restoreSuggestions()
 {
     if ($this->suggestion_objects == null && $this->suggestions) {
         $sugs = $this->suggestions;
         if ($sugs != '') {
             $sugs = json_decode($sugs, true);
             foreach ($sugs as $sug) {
                 $pi_bao = new CRM_Banking_BAO_PluginInstance();
                 $pi_bao->get('id', $sug['plugin_id']);
                 $s = new CRM_Banking_Matcher_Suggestion($pi_bao->getInstance(), $this, $sug);
                 $this->addSuggestion($s);
             }
         }
     }
 }