/**
  * Overrides parent to not only turn wpdb results into EE_Payment_Method objects,
  * but also verifies the payment method type of each is a usable object. If not,
  * deactivate it, sets a notification, and deactivates it
  * @param array $rows
  * @return EE_Payment_Method[]
  */
 protected function _create_objects($rows = array())
 {
     $payment_methods = parent::_create_objects($rows);
     /* @var $payment_methods EE_Payment_Method[] */
     $usable_payment_methods = array();
     foreach ($payment_methods as $key => $payment_method) {
         try {
             $payment_method->type_obj();
             $usable_payment_methods[$key] = $payment_method;
         } catch (EE_Error $e) {
             //if it threw an exception, its because the payment type object
             //isn't defined (probably because somehow the DB got borked,
             //or an addon which defined it got deactivated
             //so deactivate it and move on
             $payment_method->deactivate();
             $payment_method->save();
             EE_Error::add_attention(sprintf(__("There is no payment method type '%s', so the payment method '%s' was deactivated", "event_espresso"), $payment_method->type(), $payment_method->name()), __FILE__, __FUNCTION__, __LINE__);
         }
     }
     return $usable_payment_methods;
 }
 /**
  * Overrides parent to not only turn wpdb results into EE_Payment_Method objects,
  * but also verifies the payment method type of each is a usable object. If not,
  * deactivate it, sets a notification, and deactivates it
  * @param array $rows
  * @return EE_Payment_Method[]
  */
 protected function _create_objects($rows = array())
 {
     $payment_methods = parent::_create_objects($rows);
     /* @var $payment_methods EE_Payment_Method[] */
     $usable_payment_methods = array();
     foreach ($payment_methods as $key => $payment_method) {
         try {
             $payment_method->type_obj();
             $usable_payment_methods[$key] = $payment_method;
         } catch (EE_Error $e) {
             //if it threw an exception, its because the payment type object
             //isn't defined (probably because somehow the DB got borked,
             //or an addon which defined it got deactivated
             //so deactivate it and move on
             $payment_method->deactivate();
             $payment_method->save();
             EE_Error::add_attention(sprintf(__('An error occurred while attempting to use the "%1$s" payment method, so it was deactivated.%2$sWas the "%1$s" Plugin recently deactivated?%2$sIt can be reactivated on the %3$sPlugins admin page%4$s||%2$sThe actual error was:%2$s%5$s', 'event_espresso'), $payment_method->name(), '<br />', '<a href="' . admin_url('plugins.php') . '">', '</a>', $e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
         }
     }
     return $usable_payment_methods;
 }
 /**
  * Overrides parent to not only turn wpdb results into EE_Payment_Method objects,
  * but also verifies the payment method type of each is a usable object. If not,
  * deactivate it, sets a notification, and deactivates it
  * @param array $rows
  * @return EE_Payment_Method[]
  */
 protected function _create_objects($rows = array())
 {
     EE_Registry::instance()->load_lib('Payment_Method_Manager');
     $payment_methods = parent::_create_objects($rows);
     /* @var $payment_methods EE_Payment_Method[] */
     $usable_payment_methods = array();
     foreach ($payment_methods as $key => $payment_method) {
         if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) {
             $usable_payment_methods[$key] = $payment_method;
             //some payment methods enqueue their scripts in EE_PMT_*::__construct
             //which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue
             //its scripts). but for backwards-compat we should continue to do that
             $payment_method->type_obj();
         } elseif ($payment_method->active()) {
             //only deactivate and notify the admin if the payment is active somewhere
             $payment_method->deactivate();
             $payment_method->save();
             EE_Error::add_persistent_admin_notice('auto-deactivated-' . $payment_method->type(), sprintf(__('The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso'), $payment_method->admin_name(), '<br />', '<a href="' . admin_url('plugins.php') . '">', '</a>'), true);
         }
     }
     return $usable_payment_methods;
 }