comment fixes
[civicrm-core.git] / CRM / Upgrade / Incremental / Base.php
index eb21b3917d6b69c66e437b94affa3208ee058f62..5b19b3b20c6c4368dceb93897c82e3f73714daba 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6.alpha1                                         |
+ | CiviCRM version 4.7.alpha1                                         |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
@@ -63,7 +63,6 @@ class CRM_Upgrade_Incremental_Base {
    *   alterable.
    * @param string $rev
    *   an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
-   * @return void
    */
   public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
   }
@@ -103,4 +102,26 @@ class CRM_Upgrade_Incremental_Base {
     $queue->createItem($task, array('weight' => -1));
   }
 
+  /**
+   * Remove a payment processor if not in use
+   *
+   * @param CRM_Queue_TaskContext $ctx
+   * @param string $name
+   * @return bool
+   * @throws \CiviCRM_API3_Exception
+   */
+  public static function removePaymentProcessorType(CRM_Queue_TaskContext $ctx, $name) {
+    $processors = civicrm_api3('PaymentProcessor', 'getcount', array('payment_processor_type_id' => $name));
+    if (empty($processors['result'])) {
+      $result = civicrm_api3('PaymentProcessorType', 'get', array(
+        'name' => $name,
+        'return' => 'id',
+      ));
+      if (!empty($result['id'])) {
+        civicrm_api3('PaymentProcessorType', 'delete', array('id' => $result['id']));
+      }
+    }
+    return TRUE;
+  }
+
 }