class UtilsPHP in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2
Utilites (PHP native).
Hierarchy
- class \Drupal\n1ed\Flmngr\FileUploaderServer\lib\file\UtilsPHP
Expanded class hierarchy of UtilsPHP
4 files declare their use of UtilsPHP
- ActionUploadCancel.php in src/
Flmngr/ FileUploaderServer/ lib/ action/ ActionUploadCancel.php - ActionUploadCommit.php in src/
Flmngr/ FileUploaderServer/ lib/ action/ ActionUploadCommit.php - ServletConfig.php in src/
Flmngr/ FileUploaderServer/ servlet/ ServletConfig.php - UploaderServlet.php in src/
Flmngr/ FileUploaderServer/ servlet/ UploaderServlet.php
File
- src/
Flmngr/ FileUploaderServer/ lib/ file/ UtilsPHP.php, line 10
Namespace
Drupal\n1ed\Flmngr\FileUploaderServer\lib\fileView source
class UtilsPHP {
/**
* Clears a directory.
*/
public static function cleanDirectory($dir) {
UtilsPHP::delete($dir, FALSE);
}
/**
* Deletes a file or directory.
*/
public static function delete($dirOrFile, $deleteSelfDir = TRUE) {
if (is_file($dirOrFile)) {
$result = is_dir($dirOrFile) ? rmdir($dirOrFile) : unlink($dirOrFile);
if (!$result) {
throw new Exception('Unable to delete file: ' . $dirOrFile);
}
}
elseif (is_dir($dirOrFile)) {
$scan = glob(rtrim($dirOrFile, DIRECTORY_SEPARATOR) . '/*');
foreach ($scan as $path) {
UtilsPHP::delete($path);
}
if ($deleteSelfDir) {
if (!rmdir($dirOrFile)) {
throw new Exception('Unable to delete directory: ' . $dirOrFile);
}
}
}
}
/**
* Copies a file.
*/
public static function copyFile($src, $dst) {
if (!copy($src, $dst)) {
throw new Exception('Unable to copy file ' . $src . ' to ' . $dst);
}
}
/**
* Returns a path without end separator.
*/
public static function normalizeNoEndSeparator($path) {
// TODO: normalize.
return rtrim($path, DIRECTORY_SEPARATOR);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UtilsPHP:: |
public static | function | Clears a directory. | |
UtilsPHP:: |
public static | function | Copies a file. | |
UtilsPHP:: |
public static | function | Deletes a file or directory. | |
UtilsPHP:: |
public static | function | Returns a path without end separator. |