You are here

function minifyjs_remove_file in Minify JS 7

Helper function removes the file, the entry in the file_managed table and the entry in the minifyjs_file.

1 call to minifyjs_remove_file()
minifyjs_scan_for_javascript_files in ./minifyjs.admin.inc
Helper function to scan the file system for javascript files:

File

./minifyjs.admin.inc, line 492
Hook and helper functions for the Minify JS module.

Code

function minifyjs_remove_file($file_uri) {

  // Get the fid and minified uri of the file
  $result = db_select('minifyjs_file', 'm')
    ->fields('m', array(
    'fid',
    'minified_uri',
  ))
    ->condition('m.uri', $file_uri)
    ->execute();
  if ($result
    ->rowCount()) {
    $file = $result
      ->fetchObject();

    // Handle the minified file, if applicable.
    if (!empty($file->minified_uri)) {

      // Get the fid of the minified file.
      $result = db_select('file_managed', 'f')
        ->fields('f', array(
        'fid',
      ))
        ->condition('f.uri', $file->minified_uri)
        ->execute();
      if ($result
        ->rowCount()) {
        $minified_file = $result
          ->fetchObject();

        // Remove the file from the file_managed table
        $minified_file = file_load($minified_file->fid);
        file_delete($minified_file, TRUE);
      }
    }

    // Remove the file from minifyjs_file table.
    db_delete('minifyjs_file')
      ->condition('fid', $file->fid)
      ->execute();
    return TRUE;
  }
}