function SettingsForm::validateLogoPath
Helper function for the navigation settings form.
Attempts to validate normal system paths, paths relative to the public files directory, or stream wrapper URIs. If the given path is any of the above, returns a valid path or URI that the theme system can display.
Parameters
string $path: A path relative to the Drupal root or to the public files directory, or a stream wrapper URI.
Return value
string|null A valid path that can be displayed through the theme system, or NULL if the path could not be validated.
2 calls to SettingsForm::validateLogoPath()
- SettingsForm::submitForm in core/
modules/ navigation/ src/ Form/ SettingsForm.php - SettingsForm::validateForm in core/
modules/ navigation/ src/ Form/ SettingsForm.php
File
-
core/
modules/ navigation/ src/ Form/ SettingsForm.php, line 312
Class
- SettingsForm
- Configure Navigation settings for this site.
Namespace
Drupal\navigation\FormCode
protected function validateLogoPath(string $path) : ?string {
// Absolute local file paths are invalid.
if ($this->fileSystem
->realpath($path) == $path) {
return NULL;
}
// A path relative to the Drupal root or a fully qualified URI is valid.
if (is_file($path)) {
return $path;
}
// Prepend 'public://' for relative file paths within public filesystem.
if (StreamWrapperManager::getScheme($path) === FALSE) {
$path = 'public://' . $path;
}
if (is_file($path)) {
return $path;
}
return NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.