trait fileExistsOrDirectoryisWritableTrait in Acquia Content Hub 8
Trait for consistency in file checking.
@package Drupal\acquia_contenthub_audit
Hierarchy
- trait \Drupal\acquia_contenthub_audit\fileExistsOrDirectoryisWritableTrait
1 file declares its use of fileExistsOrDirectoryisWritableTrait
- AcquiaContenthubAuditCommands.php in acquia_contenthub_audit/
src/ Commands/ AcquiaContenthubAuditCommands.php
File
- acquia_contenthub_audit/
src/ fileExistsOrDirectoryisWritableTrait.php, line 10
Namespace
Drupal\acquia_contenthub_auditView source
trait fileExistsOrDirectoryisWritableTrait {
/**
* Checks whether directory/file is writable.
*/
protected function fileExistsOrDirectoryIsWritable(string $file_path) {
if (!file_exists($file_path) && !is_writable(dirname($file_path))) {
throw new \Exception(sprintf("The %s directory is not writable.", dirname($file_path)));
}
if (file_exists($file_path) && !is_writable($file_path)) {
throw new \Exception(sprintf("The %s file is not writable.", $file_path));
}
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
fileExistsOrDirectoryisWritableTrait:: |
protected | function | Checks whether directory/file is writable. |