private function FileManager::remove_file in Minify JS 8
Helper function removes the file, the entry in the file_managed table and the entry in the minifyjs_file.
Parameters
string $file_uri:
1 call to FileManager::remove_file()
- FileManager::scan in src/
Controller/ FileManager.php - Scans the system for javascript.
File
- src/
Controller/ FileManager.php, line 160
Class
- FileManager
- Controller routines for minifyjs routes.
Namespace
Drupal\minifyjs\ControllerCode
private function remove_file($file_uri) {
// Get the fid and minified uri of the file
$query = \Drupal::database()
->select('minifyjs_file', 'm')
->fields('m', array(
'fid',
'minified_uri',
))
->condition('m.uri', $file_uri);
// make sure that it exists
if ($query
->countQuery()
->execute()
->fetchField() > 0) {
$file = $query
->execute()
->fetchObject();
// Handle the minified file, if applicable.
if (!empty($file->minified_uri)) {
// Get the fid of the minified file.
$query = \Drupal::database()
->select('file_managed', 'f')
->fields('f', array(
'fid',
))
->condition('f.uri', $file->minified_uri);
if ($query
->countQuery()
->execute()
->fetchField() > 0) {
$minified_file = $query
->execute()
->fetchObject();
// Remove the file from the file_managed table
$minified_file = File::load($minified_file->fid);
$minified_file
->delete();
}
}
// Remove the file from minifyjs_file table.
\Drupal::database()
->delete('minifyjs_file')
->condition('fid', $file->fid)
->execute();
return TRUE;
}
}