Skip to content

Commit 052203c

Browse files
committed
[cookbook][doctrine] Changing entity name from Download to Document per @hhamon and @fabpot
1 parent 381c68e commit 052203c

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

cookbook/doctrine/file_uploads.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Basic Setup
2020

2121
First, create a simple Doctrine Entity class to work with::
2222

23-
// src/Acme/DemoBundle/Entity/Download.php
23+
// src/Acme/DemoBundle/Entity/Document.php
2424
namespace Acme\DemoBundle\Entity;
2525

2626
use Doctrine\ORM\Mapping as ORM;
@@ -29,7 +29,7 @@ First, create a simple Doctrine Entity class to work with::
2929
/**
3030
* @ORM\Entity
3131
*/
32-
class Download
32+
class Document
3333
{
3434
/**
3535
* @ORM\Id @ORM\Column(type="integer")
@@ -59,10 +59,10 @@ First, create a simple Doctrine Entity class to work with::
5959
}
6060
}
6161

62-
The ``Download`` entity has a name and it is associated with a file. The ``path``
62+
The ``Document`` entity has a name and it is associated with a file. The ``path``
6363
property stores the relative path to the file and is persisted to the database.
6464
The ``getFullPath()`` is a convenience method that uses the ``getUploadRootDir()``
65-
method to return the absolute path to the download file.
65+
method to return the absolute path to the file.
6666

6767
.. tip::
6868

@@ -87,13 +87,13 @@ look like this::
8787
// ...
8888
}
8989

90-
Next, create this property on your ``Download`` class and add some validation
90+
Next, create this property on your ``Document`` class and add some validation
9191
rules::
9292

93-
// src/Acme/DemoBundle/Entity/Download.php
93+
// src/Acme/DemoBundle/Entity/Document.php
9494

9595
// ...
96-
class Download
96+
class Document
9797
{
9898
/**
9999
* @Assert\File(maxSize="6000000")
@@ -111,7 +111,7 @@ rules::
111111

112112
The following controller shows you how to handle the entire process::
113113

114-
use Acme\DemoBundle\Entity\Download;
114+
use Acme\DemoBundle\Entity\Document;
115115
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
116116
// ...
117117

@@ -120,8 +120,8 @@ The following controller shows you how to handle the entire process::
120120
*/
121121
public function uploadAction()
122122
{
123-
$download = new Download();
124-
$form = $this->createFormBuilder($download)
123+
$document = new Document();
124+
$form = $this->createFormBuilder($document)
125125
->add('name')
126126
->add('file')
127127
->getForm()
@@ -132,7 +132,7 @@ The following controller shows you how to handle the entire process::
132132
if ($form->isValid()) {
133133
$em = $this->getDoctrine()->getEntityManager();
134134

135-
$em->persist($download);
135+
$em->persist($document);
136136
$em->flush();
137137

138138
$this->redirect($this->generateUrl('...'));
@@ -156,13 +156,13 @@ The following controller shows you how to handle the entire process::
156156
<input type="submit" value="Upload Document" />
157157
</form>
158158

159-
The previous controller will automatically persist the ``Download`` entity
159+
The previous controller will automatically persist the ``Document`` entity
160160
with the submitted name, but it will do nothing about the file and the ``path``
161161
property will be blank.
162162

163163
An easy way to handle the file upload is to move it just before the entity is
164164
persisted and then set the ``path`` property accordingly. Start by calling
165-
a new ``upload()`` method on the ``Download`` class, which you'll create
165+
a new ``upload()`` method on the ``Document`` class, which you'll create
166166
in a moment to handle the file upload::
167167

168168
if ($form->isValid()) {
@@ -220,19 +220,19 @@ callback::
220220
* @ORM\Entity
221221
* @ORM\HasLifecycleCallbacks
222222
*/
223-
class Download
223+
class Document
224224
{
225225
}
226226

227-
Next, refactor the ``Download`` class to take advantage of these callbacks::
227+
Next, refactor the ``Document`` class to take advantage of these callbacks::
228228

229229
use Symfony\Component\HttpFoundation\File\UploadedFile;
230230

231231
/**
232232
* @ORM\Entity
233233
* @ORM\HasLifecycleCallbacks
234234
*/
235-
class Download
235+
class Document
236236
{
237237
/**
238238
* @ORM\PrePersist()

0 commit comments

Comments
 (0)