From ced5094355a1bbf3a30981f65e814c947473f1a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Fri, 29 Jan 2016 17:43:41 +0100 Subject: [PATCH] Remove DeliverDataInterface::deliverData as never used --- .../Application/Helper/DelivererAware.php | 15 --------------- .../Phrasea/Http/DeliverDataInterface.php | 12 ------------ .../Phrasea/Http/ServeFileResponseFactory.php | 16 ---------------- .../Http/ServeFileResponseFactoryTest.php | 17 ----------------- 4 files changed, 60 deletions(-) diff --git a/lib/Alchemy/Phrasea/Application/Helper/DelivererAware.php b/lib/Alchemy/Phrasea/Application/Helper/DelivererAware.php index 797e9b41d3..06803947c7 100644 --- a/lib/Alchemy/Phrasea/Application/Helper/DelivererAware.php +++ b/lib/Alchemy/Phrasea/Application/Helper/DelivererAware.php @@ -69,19 +69,4 @@ trait DelivererAware { return $this->getDeliverer()->deliverFile($file, $filename, $disposition, $mimeType, $cacheDuration); } - - /** - * Return a HTTP Response ready to deliver data - * - * @param string $data - * @param string $filename - * @param string $mimeType - * @param string $disposition - * @param integer $cacheDuration - * @return Response - */ - public function deliverData($data, $filename, $mimeType, $disposition = DeliverDataInterface::DISPOSITION_INLINE, $cacheDuration = null) - { - return $this->getDeliverer()->deliverData($data, $filename, $disposition, $mimeType, $cacheDuration); - } } diff --git a/lib/Alchemy/Phrasea/Http/DeliverDataInterface.php b/lib/Alchemy/Phrasea/Http/DeliverDataInterface.php index e8bee8e08c..f9cfaf00f3 100644 --- a/lib/Alchemy/Phrasea/Http/DeliverDataInterface.php +++ b/lib/Alchemy/Phrasea/Http/DeliverDataInterface.php @@ -30,16 +30,4 @@ interface DeliverDataInterface * @return Response */ public function deliverFile($file, $filename = null, $disposition = self::DISPOSITION_INLINE, $mimeType = null, $cacheDuration = null); - - /** - * Return a HTTP Response ready to deliver data - * - * @param string $data - * @param string $filename - * @param string $mimeType - * @param string $disposition - * @param integer $cacheDuration - * @return Response - */ - public function deliverData($data, $filename, $mimeType, $disposition = self::DISPOSITION_INLINE, $cacheDuration = null); } diff --git a/lib/Alchemy/Phrasea/Http/ServeFileResponseFactory.php b/lib/Alchemy/Phrasea/Http/ServeFileResponseFactory.php index c84c4ceaf6..a71f656dda 100644 --- a/lib/Alchemy/Phrasea/Http/ServeFileResponseFactory.php +++ b/lib/Alchemy/Phrasea/Http/ServeFileResponseFactory.php @@ -38,22 +38,6 @@ class ServeFileResponseFactory implements DeliverDataInterface return $response; } - public function deliverData($data, $filename, $mimeType, $disposition = self::DISPOSITION_INLINE, $cacheDuration = null) - { - $response = new Response($data); - $response->headers->set('Content-Disposition', $response->headers->makeDisposition( - $disposition, - $this->sanitizeFilename($filename), - $this->sanitizeFilenameFallback($filename - ))); - $response->headers->set('Content-Type', $mimeType); - if (null !== $cacheDuration) { - $response->setMaxAge($cacheDuration); - } - - return $response; - } - private function sanitizeFilename($filename) { return str_replace(['/', '\\'], '', $filename); diff --git a/tests/Alchemy/Tests/Phrasea/Http/ServeFileResponseFactoryTest.php b/tests/Alchemy/Tests/Phrasea/Http/ServeFileResponseFactoryTest.php index 668f2a180b..fa93c06d01 100644 --- a/tests/Alchemy/Tests/Phrasea/Http/ServeFileResponseFactoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Http/ServeFileResponseFactoryTest.php @@ -139,21 +139,4 @@ class ServeFileResponseFactoryTest extends \PhraseanetWebTestCase $this->assertEquals('attachment; filename="PhraseanetTestCase.php"', $response->headers->get('content-disposition')); $this->assertEquals(realpath($file), $response->headers->get('x-accel-redirect')); } - - public function testDeliverDatas() - { - $this->factory = new ServeFileResponseFactory(new \unicode()); - - $data = 'Sex,Name,Birthday - M,Alphonse,1932 - F,Béatrice,1964 - F,Charlotte,1988'; - - $response = $this->factory->deliverData($data, 'data.csv', 'text/csv', 'attachment'); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); - $this->assertEquals('attachment; filename="data.csv"', $response->headers->get('content-disposition')); - $this->assertEquals('text/csv', $response->headers->get('content-type')); - $this->assertEquals($data, $response->getContent()); - } }