本文整理汇总了PHP中FLBuilderModel::update_services方法的典型用法代码示例。如果您正苦于以下问题:PHP FLBuilderModel::update_services方法的具体用法?PHP FLBuilderModel::update_services怎么用?PHP FLBuilderModel::update_services使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FLBuilderModel
的用法示例。
在下文中一共展示了FLBuilderModel::update_services方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect_service
/**
* Save the API connection of a service and retrieve account settings markup.
*
* Called via the fl_ajax_fl_builder_connect_service action.
*
* @since 1.5.4
* @return string The JSON encoded response.
*/
public static function connect_service()
{
$saved_services = FLBuilderModel::get_services();
$post_data = FLBuilderModel::get_post_data();
$response = array('error' => false, 'html' => '');
// Validate the service data.
if (!isset($post_data['service']) || empty($post_data['service'])) {
$response['error'] = _x('Error: Missing service type.', 'Third party service such as MailChimp.', 'fl-builder');
} else {
if (!isset($post_data['fields']) || 0 === count($post_data['fields'])) {
$response['error'] = _x('Error: Missing service data.', 'Connection data such as an API key.', 'fl-builder');
} else {
if (!isset($post_data['fields']['service_account']) || empty($post_data['fields']['service_account'])) {
$response['error'] = _x('Error: Missing account name.', 'Account name for a third party service such as MailChimp.', 'fl-builder');
}
}
}
// Get the service data.
$service = $post_data['service'];
$service_account = $post_data['fields']['service_account'];
// Does this account already exist?
if (isset($saved_services[$service][$service_account])) {
$response['error'] = _x('Error: An account with that name already exists.', 'Account name for a third party service such as MailChimp.', 'fl-builder');
}
// Try to connect to the service.
if (!$response['error']) {
$instance = self::get_service_instance($service);
$connection = $instance->connect($post_data['fields']);
if ($connection['error']) {
$response['error'] = $connection['error'];
} else {
FLBuilderModel::update_services($service, $service_account, $connection['data']);
$response['html'] = self::render_account_settings($service, $service_account);
}
}
// Return the response.
echo json_encode($response);
die;
}