public function UpdateConfigurationForm::unlinkRecursive in Config Direct Save 8
Same name and namespace in other branches
- 8.2 src/Form/UpdateConfigurationForm.php \Drupal\config_direct_save\Form\UpdateConfigurationForm::unlinkRecursive()
Delete all configurations.
1 call to UpdateConfigurationForm::unlinkRecursive()
- UpdateConfigurationForm::createConfigFiles in src/
Form/ UpdateConfigurationForm.php - Override the old configurations.
File
- src/
Form/ UpdateConfigurationForm.php, line 176
Class
- UpdateConfigurationForm
- Provide the settings form for updating configurations.
Namespace
Drupal\config_direct_save\FormCode
public function unlinkRecursive($dir_name, $ext) {
// Exit if there's no such directory.
if (!file_exists($dir_name)) {
return FALSE;
}
// Open the target directory.
$dir_handle = dir($dir_name);
// Take entries in the directory one at a time.
while (FALSE !== ($entry = $dir_handle
->read())) {
if ($entry == '.' || $entry == '..') {
continue;
}
$abs_name = "{$dir_name}/{$entry}";
if (is_file($abs_name) && preg_match("/^.+\\.{$ext}\$/", $entry)) {
if (unlink($abs_name)) {
continue;
}
return FALSE;
}
// Recurse on the children if the current entry
// happens to be a "directory".
if (is_dir($abs_name) || is_link($abs_name)) {
$this
->unlinkRecursive($abs_name, $ext);
}
}
$dir_handle
->close();
return TRUE;
}