Skip to content

Commit a03f06f

Browse files
committed
Merge branch '2.0' into 2.1
Conflicts: cookbook/testing/doctrine.rst cookbook/testing/profiling.rst
2 parents 760d20e + b1eb34a commit a03f06f

File tree

9 files changed

+89
-33
lines changed

9 files changed

+89
-33
lines changed

book/translation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ steps:
994994
.. _`i18n`: http://en.wikipedia.org/wiki/Internationalization_and_localization
995995
.. _`L10n`: http://en.wikipedia.org/wiki/Internationalization_and_localization
996996
.. _`strtr function`: http://www.php.net/manual/en/function.strtr.php
997-
.. _`ISO 31-11`: http://en.wikipedia.org/wiki/Interval_%28mathematics%29#The_ISO_notation
997+
.. _`ISO 31-11`: http://en.wikipedia.org/wiki/Interval_(mathematics)#Notations_for_intervals
998998
.. _`Translatable Extension`: https://github.com/l3pp4rd/DoctrineExtensions
999999
.. _`ISO3166 Alpha-2`: http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes
10001000
.. _`ISO639-1`: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

cookbook/doctrine/file_uploads.rst

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,29 @@ First, create a simple Doctrine Entity class to work with::
5555

5656
public function getAbsolutePath()
5757
{
58-
return null === $this->path ? null : $this->getUploadRootDir().'/'.$this->path;
58+
return null === $this->path
59+
? null
60+
: $this->getUploadRootDir().'/'.$this->path;
5961
}
6062

6163
public function getWebPath()
6264
{
63-
return null === $this->path ? null : $this->getUploadDir().'/'.$this->path;
65+
return null === $this->path
66+
? null
67+
: $this->getUploadDir().'/'.$this->path;
6468
}
6569

6670
protected function getUploadRootDir()
6771
{
68-
// the absolute directory path where uploaded documents should be saved
72+
// the absolute directory path where uploaded
73+
// documents should be saved
6974
return __DIR__.'/../../../../web/'.$this->getUploadDir();
7075
}
7176

7277
protected function getUploadDir()
7378
{
74-
// get rid of the __DIR__ so it doesn't screw when displaying uploaded doc/image in the view.
79+
// get rid of the __DIR__ so it doesn't screw up
80+
// when displaying uploaded doc/image in the view.
7581
return 'uploads/documents';
7682
}
7783
}
@@ -213,8 +219,12 @@ object, which is what's returned after a ``file`` field is submitted::
213219
// use the original file name here but you should
214220
// sanitize it at least to avoid any security issues
215221

216-
// move takes the target directory and then the target filename to move to
217-
$this->file->move($this->getUploadRootDir(), $this->file->getClientOriginalName());
222+
// move takes the target directory and then the
223+
// target filename to move to
224+
$this->file->move(
225+
$this->getUploadRootDir(),
226+
$this->file->getClientOriginalName()
227+
);
218228

219229
// set the path property to the filename where you've saved the file
220230
$this->path = $this->file->getClientOriginalName();
@@ -266,7 +276,8 @@ Next, refactor the ``Document`` class to take advantage of these callbacks::
266276
{
267277
if (null !== $this->file) {
268278
// do whatever you want to generate a unique name
269-
$this->path = sha1(uniqid(mt_rand(), true)).'.'.$this->file->guessExtension();
279+
$filename = sha1(uniqid(mt_rand(), true));
280+
$this->path = $filename.'.'.$this->file->guessExtension();
270281
}
271282
}
272283

@@ -373,7 +384,10 @@ property, instead of the actual filename::
373384
// you must throw an exception here if the file cannot be moved
374385
// so that the entity is not persisted to the database
375386
// which the UploadedFile move() method does
376-
$this->file->move($this->getUploadRootDir(), $this->id.'.'.$this->file->guessExtension());
387+
$this->file->move(
388+
$this->getUploadRootDir(),
389+
$this->id.'.'.$this->file->guessExtension()
390+
);
377391

378392
unset($this->file);
379393
}
@@ -398,7 +412,9 @@ property, instead of the actual filename::
398412

399413
public function getAbsolutePath()
400414
{
401-
return null === $this->path ? null : $this->getUploadRootDir().'/'.$this->id.'.'.$this->path;
415+
return null === $this->path
416+
? null
417+
: $this->getUploadRootDir().'/'.$this->id.'.'.$this->path;
402418
}
403419
}
404420

cookbook/doctrine/multiple_entity_managers.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ two connections, one for each entity manager.
6464

6565
.. note::
6666

67-
When working with multiple connections and entity managers, you should be
67+
When working with multiple connections and entity managers, you should be
6868
explicit about which configuration you want. If you *do* omit the name of
6969
the connection or entity manager, the default (i.e. ``default``) is used.
7070

@@ -98,7 +98,7 @@ the default entity manager (i.e. ``default``) is returned::
9898
// both return the "default" em
9999
$em = $this->get('doctrine')->getManager();
100100
$em = $this->get('doctrine')->getManager('default');
101-
101+
102102
$customerEm = $this->get('doctrine')->getManager('customer');
103103
}
104104
}
@@ -115,17 +115,20 @@ The same applies to repository call::
115115
{
116116
// Retrieves a repository managed by the "default" em
117117
$products = $this->get('doctrine')
118-
->getRepository('AcmeStoreBundle:Product')
119-
->findAll();
118+
->getRepository('AcmeStoreBundle:Product')
119+
->findAll()
120+
;
120121

121122
// Explicit way to deal with the "default" em
122123
$products = $this->get('doctrine')
123-
->getRepository('AcmeStoreBundle:Product', 'default')
124-
->findAll();
124+
->getRepository('AcmeStoreBundle:Product', 'default')
125+
->findAll()
126+
;
125127

126128
// Retrieves a repository managed by the "customer" em
127129
$customers = $this->get('doctrine')
128-
->getRepository('AcmeCustomerBundle:Customer', 'customer')
129-
->findAll();
130+
->getRepository('AcmeCustomerBundle:Customer', 'customer')
131+
->findAll()
132+
;
130133
}
131134
}

cookbook/doctrine/registration_form.rst

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ Next, create the form for this ``Registration`` model::
194194
public function buildForm(FormBuilderInterface $builder, array $options)
195195
{
196196
$builder->add('user', new UserType());
197-
$builder->add('terms', 'checkbox', array('property_path' => 'termsAccepted'));
197+
$builder->add(
198+
'terms',
199+
'checkbox',
200+
array('property_path' => 'termsAccepted')
201+
);
198202
}
199203

200204
public function getName()
@@ -227,9 +231,15 @@ controller for displaying the registration form::
227231
{
228232
public function registerAction()
229233
{
230-
$form = $this->createForm(new RegistrationType(), new Registration());
231-
232-
return $this->render('AcmeAccountBundle:Account:register.html.twig', array('form' => $form->createView()));
234+
$form = $this->createForm(
235+
new RegistrationType(),
236+
new Registration()
237+
);
238+
239+
return $this->render(
240+
'AcmeAccountBundle:Account:register.html.twig',
241+
array('form' => $form->createView())
242+
);
233243
}
234244
}
235245

@@ -264,7 +274,10 @@ the validation and saves the data into the database::
264274
return $this->redirect(...);
265275
}
266276

267-
return $this->render('AcmeAccountBundle:Account:register.html.twig', array('form' => $form->createView()));
277+
return $this->render(
278+
'AcmeAccountBundle:Account:register.html.twig',
279+
array('form' => $form->createView())
280+
);
268281
}
269282

270283
That's it! Your form now validates, and allows you to save the ``User``

cookbook/email/dev_environment.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ Now, suppose you're sending an email to ``recipient@example.com``.
9696
->setSubject('Hello Email')
9797
->setFrom('send@example.com')
9898
->setTo('recipient@example.com')
99-
->setBody($this->renderView('HelloBundle:Hello:email.txt.twig', array('name' => $name)))
99+
->setBody(
100+
$this->renderView(
101+
'HelloBundle:Hello:email.txt.twig',
102+
array('name' => $name)
103+
)
104+
)
100105
;
101106
$this->get('mailer')->send($message);
102107
@@ -150,10 +155,10 @@ you to open the report with details of the sent emails.
150155
151156
<!-- app/config/config_dev.xml -->
152157
153-
<!--
158+
<!--
154159
xmlns:webprofiler="http://symfony.com/schema/dic/webprofiler"
155-
xsi:schemaLocation="http://symfony.com/schema/dic/webprofiler
156-
http://symfony.com/schema/dic/webprofiler/webprofiler-1.0.xsd">
160+
xsi:schemaLocation="http://symfony.com/schema/dic/webprofiler
161+
http://symfony.com/schema/dic/webprofiler/webprofiler-1.0.xsd">
157162
-->
158163
159164
<webprofiler:config

cookbook/email/email.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ an email is pretty straightforward::
106106
->setSubject('Hello Email')
107107
->setFrom('send@example.com')
108108
->setTo('recipient@example.com')
109-
->setBody($this->renderView('HelloBundle:Hello:email.txt.twig', array('name' => $name)))
109+
->setBody(
110+
$this->renderView(
111+
'HelloBundle:Hello:email.txt.twig',
112+
array('name' => $name)
113+
)
114+
)
110115
;
111116
$this->get('mailer')->send($message);
112117

cookbook/form/form_collections.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,9 @@ the relationship between the removed ``Tag`` and ``Task`` object.
607607
$originalTags = array();
608608

609609
// Create an array of the current Tag objects in the database
610-
foreach ($task->getTags() as $tag) $originalTags[] = $tag;
610+
foreach ($task->getTags() as $tag) {
611+
$originalTags[] = $tag;
612+
}
611613

612614
$editForm = $this->createForm(new TaskType(), $task);
613615

cookbook/testing/doctrine.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ which makes all of this quite easy::
3939
{
4040
static::$kernel = static::createKernel();
4141
static::$kernel->boot();
42-
$this->em = static::$kernel->getContainer()->get('doctrine')->getManager();
42+
$this->em = static::$kernel->getContainer()
43+
->get('doctrine')
44+
->getManager()
45+
;
4346
}
4447

4548
public function testSearchByCategoryName()

cookbook/testing/profiling.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ environment)::
2727
// Check that the profiler is enabled
2828
if ($profile = $client->getProfile()) {
2929
// check the number of requests
30-
$this->assertLessThan(10, $profile->getCollector('db')->getQueryCount());
30+
$this->assertLessThan(
31+
10,
32+
$profile->getCollector('db')->getQueryCount()
33+
);
3134

3235
// check the time spent in the framework
33-
$this->assertLessThan(500, $profile->getCollector('time')->getTotalTime());
36+
$this->assertLessThan(
37+
500,
38+
$profile->getCollector('time')->getTotalTime()
39+
);
3440
}
3541
}
3642
}
@@ -42,7 +48,10 @@ finish. It's easy to achieve if you embed the token in the error message::
4248
$this->assertLessThan(
4349
30,
4450
$profile->get('db')->getQueryCount(),
45-
sprintf('Checks that query count is less than 30 (token %s)', $profile->getToken())
51+
sprintf(
52+
'Checks that query count is less than 30 (token %s)',
53+
$profile->getToken()
54+
)
4655
);
4756

4857
.. caution::

0 commit comments

Comments
 (0)