mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Remove DeliverDataInterface::deliverData as never used
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user