fileExistsOrDirectoryisWritableTrait.php in Acquia Content Hub 8
File
acquia_contenthub_audit/src/fileExistsOrDirectoryisWritableTrait.php
View source
<?php
namespace Drupal\acquia_contenthub_audit;
trait fileExistsOrDirectoryisWritableTrait {
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;
}
}