Skip to content
Snippets Groups Projects
Commit 2cc6da73 authored by Eric Bremner's avatar Eric Bremner Committed by Igor Biki
Browse files

ISTWCMS-5804: adding function to uw service to check for valid external url

parent 85bd8cda
No related branches found
No related tags found
1 merge request!271Feature/istwcms 5804 ebremner site logo fixes
...@@ -594,4 +594,20 @@ class UWService implements UWServiceInterface { ...@@ -594,4 +594,20 @@ class UWService implements UWServiceInterface {
return $list; return $list;
} }
/**
* {@inheritDoc}
*/
public function validExternalUrl(string $url): bool {
// Get the headers of the URL.
$headers = @get_headers($url);
// Use condition to check if there is no URL.
if($headers && strpos( $headers[0], '404')) {
return FALSE;
}
return TRUE;
}
} }
...@@ -211,4 +211,14 @@ interface UWServiceInterface { ...@@ -211,4 +211,14 @@ interface UWServiceInterface {
*/ */
public function getContentTypeUsage(array $content_types, bool $show_null_content_types): array; public function getContentTypeUsage(array $content_types, bool $show_null_content_types): array;
/**
* Function to check if an external url is valid.
*
* @param string $url
* The URL to be checked.
*
* @return bool
* Whether url is valid or not.
*/
public function validExternalUrl(string $url): bool;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment