/** * {@inheritDoc} */ public function onUpload(PostPersistEvent $event) { // Create and persist a file history object $fileHistory = $this->createFileHistory($event); // Add filename information to response $response = $event->getResponse(); $response['filename'] = $fileHistory->getFileName(); $response['originalname'] = $fileHistory->getOriginalName(); $response['filepath'] = $this->fileHistoryManager->getUrl($fileHistory); return $response; }
/** * {@inheritDoc} */ public function buildView(FormView $view, FormInterface $form, array $options) { $fileHistory = null; $fileHistoryUrl = null; if ($form->getData() !== null) { $fileHistory = $this->fileHistoryManager->findOneByFileName($form->getData()); $fileHistoryUrl = $this->fileHistoryManager->getUrl($fileHistory, $options['resolver_key']); } $className = 'jb_result_filename'; if (isset($view->vars['attr']['class'])) { $view->vars['attr']['class'] .= ' ' . $className; } else { $view->vars['attr']['class'] = $className; } $view->vars['file_history'] = $fileHistory; $view->vars['file_history_url'] = $fileHistoryUrl; $view->vars['endpoint'] = $options['endpoint']; $view->vars['download_link'] = $options['download_link']; $view->vars['remove_link'] = $options['remove_link']; $view->vars['loading_file'] = $options['loading_file']; $view->vars['use_crop'] = false; }