function link_ensure_valid_default_protocol in Link 7
Validate that the protocol is either HTTP or HTTPS.
Throws
Exception
2 calls to link_ensure_valid_default_protocol()
- LinkDefaultProtocolTest::testHttpDefaultProtocolFromVariableConf in tests/
LinkDefaultProtocolTest.test - The protocol is set to HTTP by default if a wrong protocol has been set.
- link_cleanup_url in ./
link.module - Forms a valid URL if possible from an entered address.
File
- ./
link.module, line 1599 - Defines simple link field types.
Code
function link_ensure_valid_default_protocol() {
$protocol = variable_get('link_default_protocol', LINK_HTTP_PROTOCOL);
if ($protocol !== LINK_HTTP_PROTOCOL && $protocol !== LINK_HTTPS_PROTOCOL) {
variable_set('link_default_protocol', LINK_HTTP_PROTOCOL);
throw new Exception(t('Protocol was set to !protocol but must be !HTTP or !HTTPS. Set to default HTTP.', array(
'!protocol' => $protocol,
'!HTTP' => LINK_HTTP_PROTOCOL,
'!HTTPS' => LINK_HTTPS_PROTOCOL,
)));
}
}