本文整理汇总了PHP中EEM_Base::_create_objects方法的典型用法代码示例。如果您正苦于以下问题:PHP EEM_Base::_create_objects方法的具体用法?PHP EEM_Base::_create_objects怎么用?PHP EEM_Base::_create_objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EEM_Base
的用法示例。
在下文中一共展示了EEM_Base::_create_objects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _create_objects
/**
* 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;
}
示例2: _create_objects
/**
* 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;
}
示例3: _create_objects
/**
* 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;
}