app = $app; } public function deliverContent(Request $request, \record_adapter $record, $subdef, $watermark, $stamp) { $mediaSubdefinition = $record->get_subdef($subdef); $pathOut = $mediaSubdefinition->get_pathfile(); if ($watermark === true && $mediaSubdefinition->get_type() === \media_subdef::TYPE_IMAGE) { $pathOut = \recordutils_image::watermark($this->app, $mediaSubdefinition); } elseif ($stamp === true && $mediaSubdefinition->get_type() === \media_subdef::TYPE_IMAGE) { $pathOut = \recordutils_image::stamp($this->app, $mediaSubdefinition); } $disposition = $request->query->get('download') ? DeliverDataInterface::DISPOSITION_ATTACHMENT : DeliverDataInterface::DISPOSITION_INLINE; $response = $this->deliverFile($pathOut, $mediaSubdefinition->get_file(), $disposition, $mediaSubdefinition->get_mime()); if (in_array($subdef, array('document', 'preview'))) { $response->setPrivate(); $this->logView($record, $request); } elseif ($subdef !== 'thumbnail') { try { if ($mediaSubdefinition->getDataboxSubdef()->get_class() != \databox_subdef::CLASS_THUMBNAIL) { $response->setPrivate(); $this->logView($record, $request); } } catch (\Exception $e) { // Ignore exception } } $response->isNotModified($request); return $response; } private function logView(\record_adapter $record, Request $request) { try { $logger = $this->getDataboxLogger($record->get_databox()); $log_id = $logger->get_id(); $record->log_view( $log_id, $request->headers->get('referer', 'NO REFERRER'), $this->app['phraseanet.configuration']['main']['key'] ) ; } catch (\Exception $e) { // Ignore exception } } }