Skip to content

Instantly share code, notes, and snippets.

View benjamin-dk's full-sized avatar

Benjamin Christensen benjamin-dk

  • Aarhus Universitetshospital
View GitHub Profile
@benjamin-dk
benjamin-dk / delete_dir.php
Last active June 22, 2017 08:21
How to delete directory with PHP on FreeBSD
<?php
/* Its been a while since I used this so please use at your own risk */
function deleteDir($dirPath) {
if (! is_dir($dirPath)) {
throw new InvalidArgumentException("$dirPath must be a directory");
}
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
$dirPath .= '/';
}
$files = glob($dirPath . '*', GLOB_MARK);
@benjamin-dk
benjamin-dk / php
Created September 11, 2024 10:08
Drupal 10 - persisting values in forms when validation fails (SimpleForm.php from the Examples module)
<?php
namespace Drupal\form_api_example\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements the SimpleForm form controller.
*