diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-16 16:48:11 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-03 14:00:33 +0100 |
commit | 5466fbf761bfb810a43b11789b03b2ec54c9ab6e (patch) | |
tree | 273bee9e8a91c6559ba5ff4e1c6514d4ef3e5c22 /core/Controller/PreviewController.php | |
parent | 8468212386fa577a60df238c10243b8297e962fc (diff) | |
download | nextcloud-server-5466fbf761bfb810a43b11789b03b2ec54c9ab6e.tar.gz nextcloud-server-5466fbf761bfb810a43b11789b03b2ec54c9ab6e.zip |
Move Ipreview to more of DI thingy
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'core/Controller/PreviewController.php')
-rw-r--r-- | core/Controller/PreviewController.php | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/core/Controller/PreviewController.php b/core/Controller/PreviewController.php index 425617813fa..f54681a856b 100644 --- a/core/Controller/PreviewController.php +++ b/core/Controller/PreviewController.php @@ -23,15 +23,14 @@ namespace OC\Core\Controller; -use OC\PreviewManager; +use OC\DatabaseException; use OCP\AppFramework\Controller; use OCP\Files\File; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; -use OCP\Files\IAppData; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; -use OCP\IConfig; +use OCP\IPreview; use OCP\IRequest; class PreviewController extends Controller { @@ -42,29 +41,28 @@ class PreviewController extends Controller { /** @var IRootFolder */ private $root; - /** @var IConfig */ - private $config; - - /** @var PreviewManager */ - private $previewManager; - - /** @var IAppData */ - private $appData; + /** @var IPreview */ + private $preview; + /** + * PreviewController constructor. + * + * @param string $appName + * @param IRequest $request + * @param IPreview $preview + * @param IRootFolder $root + * @param string $userId + */ public function __construct($appName, IRequest $request, + IPreview $preview, IRootFolder $root, - IConfig $config, - PreviewManager $previewManager, - IAppData $appData, $userId ) { parent::__construct($appName, $request); - $this->previewManager = $previewManager; + $this->preview = $preview; $this->root = $root; - $this->config = $config; - $this->appData = $appData; $this->userId = $userId; } @@ -103,21 +101,17 @@ class PreviewController extends Controller { return new DataResponse([], Http::STATUS_NOT_FOUND); } - if (!($file instanceof File) || (!$forceIcon && !$this->previewManager->isAvailable($file))) { + if (!($file instanceof File) || (!$forceIcon && !$this->preview->isAvailable($file))) { return new DataResponse([], Http::STATUS_NOT_FOUND); } else if (!$file->isReadable()) { return new DataResponse([], Http::STATUS_FORBIDDEN); } - $preview = new \OC\Preview\Generator( - $this->root, - $this->config, - $this->previewManager, - $file, - $this->appData - ); - - $f = $preview->getPreview($x, $y, !$a, $mode); + try { + $f = $this->preview->getPreview($file, $x, $y, !$a, $mode); + } catch (NotFoundException $e) { + return new DataResponse([], Http::STATUS_NOT_FOUND); + } return new Http\FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); } } |