Exemple #1
0
 public static function init($className, $isActive = true, $isDefault = false)
 {
     //If the $isActive parameter is false, do not do anything. This will be useful if we store the plugins in the database
     //The $isDefault parameter will change the default payment plugin
     if (!$isActive) {
         return;
     }
     if (!isset(ECommPayment::$activePaymentPlugin[$className])) {
         require "{$className}.php";
         ECommPayment::$activePaymentPlugin[$className] = new $className();
     }
     //If this is the first plugin, make it the default one
     if (count(ECommPayment::$activePaymentPlugin) == 1) {
         $isDefault = true;
     }
     if ($isDefault) {
         //If a plugin is the default payment class:
         //First, set the defaultPlugin variable to the name of this class
         //Second, change the order of the array becuase the default plugin MUST always be the first payment plugin
         ECommPayment::$defaultPlugin = $className;
         $tempArray = ECommPayment::$activePaymentPlugin;
         ECommPayment::$activePaymentPlugin = array();
         ECommPayment::$activePaymentPlugin[$className] = $tempArray[$className];
         //Put the default plugin at the beginning
         foreach ($tempArray as $key => $val) {
             ECommPayment::$activePaymentPlugin[$key] = $val;
         }
     }
 }