@@ -20,7 +20,7 @@ Basic Setup
20
20
21
21
First, create a simple Doctrine Entity class to work with::
22
22
23
- // src/Acme/DemoBundle/Entity/Download .php
23
+ // src/Acme/DemoBundle/Entity/Document .php
24
24
namespace Acme\DemoBundle\Entity;
25
25
26
26
use Doctrine\ORM\Mapping as ORM;
@@ -29,7 +29,7 @@ First, create a simple Doctrine Entity class to work with::
29
29
/**
30
30
* @ORM\Entity
31
31
*/
32
- class Download
32
+ class Document
33
33
{
34
34
/**
35
35
* @ORM\Id @ORM\Column(type="integer")
@@ -59,10 +59,10 @@ First, create a simple Doctrine Entity class to work with::
59
59
}
60
60
}
61
61
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 ``
63
63
property stores the relative path to the file and is persisted to the database.
64
64
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.
66
66
67
67
.. tip ::
68
68
@@ -87,13 +87,13 @@ look like this::
87
87
// ...
88
88
}
89
89
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
91
91
rules::
92
92
93
- // src/Acme/DemoBundle/Entity/Download .php
93
+ // src/Acme/DemoBundle/Entity/Document .php
94
94
95
95
// ...
96
- class Download
96
+ class Document
97
97
{
98
98
/**
99
99
* @Assert\File(maxSize="6000000")
@@ -111,7 +111,7 @@ rules::
111
111
112
112
The following controller shows you how to handle the entire process::
113
113
114
- use Acme\DemoBundle\Entity\Download ;
114
+ use Acme\DemoBundle\Entity\Document ;
115
115
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
116
116
// ...
117
117
@@ -120,8 +120,8 @@ The following controller shows you how to handle the entire process::
120
120
*/
121
121
public function uploadAction()
122
122
{
123
- $download = new Download ();
124
- $form = $this->createFormBuilder($download )
123
+ $document = new Document ();
124
+ $form = $this->createFormBuilder($document )
125
125
->add('name')
126
126
->add('file')
127
127
->getForm()
@@ -132,7 +132,7 @@ The following controller shows you how to handle the entire process::
132
132
if ($form->isValid()) {
133
133
$em = $this->getDoctrine()->getEntityManager();
134
134
135
- $em->persist($download );
135
+ $em->persist($document );
136
136
$em->flush();
137
137
138
138
$this->redirect($this->generateUrl('...'));
@@ -156,13 +156,13 @@ The following controller shows you how to handle the entire process::
156
156
<input type="submit" value="Upload Document" />
157
157
</form>
158
158
159
- The previous controller will automatically persist the ``Download `` entity
159
+ The previous controller will automatically persist the ``Document `` entity
160
160
with the submitted name, but it will do nothing about the file and the ``path ``
161
161
property will be blank.
162
162
163
163
An easy way to handle the file upload is to move it just before the entity is
164
164
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
166
166
in a moment to handle the file upload::
167
167
168
168
if ($form->isValid()) {
@@ -220,19 +220,19 @@ callback::
220
220
* @ORM\Entity
221
221
* @ORM\HasLifecycleCallbacks
222
222
*/
223
- class Download
223
+ class Document
224
224
{
225
225
}
226
226
227
- Next, refactor the ``Download `` class to take advantage of these callbacks::
227
+ Next, refactor the ``Document `` class to take advantage of these callbacks::
228
228
229
229
use Symfony\Component\HttpFoundation\File\UploadedFile;
230
230
231
231
/**
232
232
* @ORM\Entity
233
233
* @ORM\HasLifecycleCallbacks
234
234
*/
235
- class Download
235
+ class Document
236
236
{
237
237
/**
238
238
* @ORM\PrePersist()
0 commit comments