You are here

public function FlippingBook::prepareExportDirectory in Flipping Book 8

Prepare export directory.

Parameters

\Drupal\file\Entity\File $file: A File entity.

string $export_location: The export location path.

Return value

array An array with filepath and destination info.

Overrides FlippingBookInterface::prepareExportDirectory

File

src/FlippingBook.php, line 75

Class

FlippingBook
Class FlippingBook.

Namespace

Drupal\flipping_book

Code

public function prepareExportDirectory(File $file, $export_location) {
  $filepath = $this->fileSystem
    ->realpath($file
    ->getFileUri());
  $dir = pathinfo($this
    ->cleanFilename($file
    ->getFilename()), PATHINFO_FILENAME);
  $this->fileSystem
    ->prepareDirectory($export_location, FileSystemInterface::CREATE_DIRECTORY);
  $destination = $this->fileSystem
    ->getDestinationFilename($export_location . '/' . $dir, FileSystemInterface::EXISTS_RENAME);
  return [
    'filepath' => $filepath,
    'destination' => $destination,
  ];
}