protected function FlippingBookForm::handleArchive in Flipping Book 8
Handle uploaded archive.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: Form state instance.
1 call to FlippingBookForm::handleArchive()
- FlippingBookForm::save in src/
Form/ FlippingBookForm.php - Form submission handler for the 'save' action.
File
- src/
Form/ FlippingBookForm.php, line 181
Class
- FlippingBookForm
- Form controller for Flipping Book edit forms.
Namespace
Drupal\flipping_book\FormCode
protected function handleArchive(FormStateInterface $form_state) {
$file = $form_state
->getValue('file');
if (!empty($file[0]['fids'])) {
$this
->prepareExport($form_state);
try {
$this->flippingBook
->extractArchive($this->filepath, $this->destination);
} catch (\Exception $e) {
$message = $this
->t('Cannot extract Flipping Book file: @message', [
'@message' => $e
->getMessage(),
]);
$this
->messenger()
->addError($message);
return;
}
$this->entity
->set('directory', str_replace($this
->getUploadLocation() . '/', '', $this->destination));
return;
}
$storage = $this->entityTypeManager
->getStorage('flipping_book');
$orig = $storage
->load($this->entity
->id());
if (!empty($orig
->get('file')
->getValue()) && empty($this->entity
->get('file')
->getValue())) {
$this
->deleteFlippingBook($orig);
}
}