public function DirectoryOperations::directoryRemove in AT Tool 2.0 1.0.x
Delete a folder and all files recursively.
Parameters
$directory:
Return value
bool Returns TRUE on success, FALSE on failure Returns TRUE on success, FALSE on failure
File
- at_theme_generator/
src/ File/ DirectoryOperations.php, line 67
Class
Namespace
Drupal\at_theme_generator\FileCode
public function directoryRemove($directory) {
if (!file_exists($directory)) {
return FALSE;
}
if (is_file($directory)) {
return \Drupal::service('file_system')
->unlink($directory);
}
$dir = dir($directory);
while (FALSE !== ($entry = $dir
->read())) {
if ($entry == '.' || $entry == '..') {
continue;
}
self::directoryRemove("{$directory}/{$entry}");
}
$dir
->close();
return \Drupal::service('file_system')
->rmdir($directory);
}