本文整理汇总了PHP中repository::type_form_validation方法的典型用法代码示例。如果您正苦于以下问题:PHP repository::type_form_validation方法的具体用法?PHP repository::type_form_validation怎么用?PHP repository::type_form_validation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类repository
的用法示例。
在下文中一共展示了repository::type_form_validation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: type_form_validation
public static function type_form_validation($mform, $data, $errors)
{
if (!empty($data['filters']) && !json_decode($data['filters'])) {
$errors['filters'] = get_string('invalid_filters', 'repository_entermedia');
}
try {
$client = new Client(array('base_uri' => $data['uri'] . 'mediadb/services/'));
$response = $client->get('system/systemstatus');
if ($response->getStatusCode() === 200) {
$body = json_decode($response->getBody());
if (!$body || $body->response->status !== 'ok') {
$errors['uri'] = get_string('uri_notok', 'repository_entermedia');
}
} else {
$errors['uri'] = get_string('uri_statuscode', 'repository_entermedia') . $response->getStatusCode();
}
} catch (GuzzleException $e) {
$errors['uri'] = get_string('uri_exception', 'repository_entermedia');
}
if (isset($data['autologin_enable'])) {
if (!repository_entermedia::static_try_login($data['uri'], $data['autologin_user'], $data['autologin_password'])) {
$errors['autologin_enable'] = get_string('autologin_error', 'repository_entermedia');
}
}
// A little bit hacky to empty the cache here...
$cache = cache::make('repository_entermedia', 'filters');
$cache->delete('filters');
return parent::type_form_validation($mform, $data, $errors);
}