You are here

function epub_file_update in Epub 8

Same name and namespace in other branches
  1. 7 epub.module \epub_file_update()

Implements hook_file_update().

File

./epub.module, line 65

Code

function epub_file_update(File $file) {
  $destination = 'public://epub_content/' . $file
    ->id();
  $tmp = explode('.', $file
    ->getFilename());
  $file_extension = end($tmp);
  switch ($file_extension) {
    case 'epub':
      file_prepare_directory($destination, FILE_CREATE_DIRECTORY);
      return epub_unzip(drupal_realpath($file
        ->getFileUri()), $destination);
    case 'ibooks':
      file_prepare_directory($destination, FILE_CREATE_DIRECTORY);
      return epub_unzip(drupal_realpath($file
        ->getFileUri()), $destination);
  }
}