Skip to content

Commit 643c0d4

Browse files
committed
Tweak section to remove some text
1 parent 42d647d commit 643c0d4

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

book/controller.rst

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,12 @@ There are also special classes to make certain kinds of responses easier:
782782
:class:`Symfony\\Component\\HttpFoundation\\StreamedResponse`.
783783
See :ref:`streaming-response`.
784784

785+
.. seealso::
786+
787+
Now that you know the basics you can continue your research on Symfony
788+
``Request`` and ``Response`` object in the
789+
:ref:`HttpFoundation component documentation <component-http-foundation-request>`.
790+
785791
JSON Helper
786792
~~~~~~~~~~~
787793

@@ -809,46 +815,39 @@ the :phpfunction:`json_encode` function is used.
809815
File helper
810816
~~~~~~~~~~~
811817

812-
If you want to serve file use the
813-
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::file`
814-
helper::
815-
816-
$this->file($file, $fileName = null, $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT);
818+
.. versionadded:: 3.2
819+
The ``file()`` helper was introduced in Symfony 3.2.
817820

818-
You can pass:
821+
You can use :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::file`
822+
to serve a file from inside a controller::
819823

820-
* An instance of
821-
:class:`Symfony\\Component\\HttpFoundation\\File`
822-
in ``$file`` parameter (you can customize ``$fileName`` and ``$disposition``)
824+
$this->file($file, $fileName = null, $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT);
823825

824-
* Path to file in ``$file`` parameter
826+
You can pass an :phpclass:`SplFileInfo` instance (like
827+
:class:`Symfony\\Component\\HttpFoundation\\File`) or the path to a file as
828+
first argument. Using the second and third arguments, you can customize the
829+
send filename and the disposition.
825830

826-
Example usage::
831+
.. code-block:: php
827832
828833
use Symfony\Component\HttpFoundation\File\File;
829834
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
830835
831-
// This will send file with original name as attachment to browser
832836
public function fileAction()
833837
{
834-
// Load file from file system
838+
// load file from the file system
835839
$file = new File('some_file.pdf');
836840
837-
return $this->file($file);
841+
// send the file as attachment to browser
842+
return $this->file($file, 'custom_name.pdf');
838843
}
839844
840-
// Server file from specified path
841845
public function pathFileAction()
842846
{
847+
// serve file from specified path
843848
return $this->file('/path/to/my/picture.jpg');
844849
}
845850
846-
.. seealso::
847-
848-
Now that you know the basics you can continue your research on Symfony
849-
``Request`` and ``Response`` object in the
850-
:ref:`HttpFoundation component documentation <component-http-foundation-request>`.
851-
852851
Creating Static Pages
853852
---------------------
854853

0 commit comments

Comments
 (0)