Skip to content

Commit 585644b

Browse files
committed
Merge branch '2.3' into 2.5
* 2.3: Fixing typo thanks to xabbuh fixed typo (acme -> app) Fix typo: missing space Adding reference link Quick proofread of the email cookbook Remove horizontal scrollbar Fix typos Fix typo, remove horizontal scrollbar Set twig service as private added Kévin as a merger for the Serializer component Fix typo: looks => look Align methods in YAML example Move annotations example to front Fixed typo fixed indentation restore the how to NOT do it example in the "Service: No Class Parameter" section Remove note that's no longer the case
2 parents 768650e + 3921d70 commit 585644b

File tree

14 files changed

+95
-81
lines changed

14 files changed

+95
-81
lines changed

best_practices/business-logic.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,12 @@ the class namespace as a parameter:
140140
# app/config/services.yml
141141
142142
# service definition with class namespace as parameter
143+
parameters:
144+
slugger.class: AppBundle\Utils\Slugger
145+
143146
services:
144147
app.slugger:
145-
class: AppBundle\Utils\Slugger
148+
class: "%slugger.class%"
146149
147150
This practice is cumbersome and completely unnecessary for your own services:
148151

best_practices/configuration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ and security credentials) and different environments (development, production).
66
That's why Symfony recommends that you split the application configuration into
77
three parts.
88

9+
.. _config-parameters.yml:
10+
911
Infrastructure-Related Configuration
1012
------------------------------------
1113

components/class_loader/class_map_generator.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Generating a Class Map
4545
----------------------
4646

4747
To generate the class map, simply pass the root directory of your class files
48-
to the :method:`Symfony\\Component\\ClassLoader\\ClassMapGenerator::createMap``
48+
to the :method:`Symfony\\Component\\ClassLoader\\ClassMapGenerator::createMap`
4949
method::
5050

5151
use Symfony\Component\ClassLoader\ClassMapGenerator;
@@ -115,7 +115,10 @@ the same as in the example above)::
115115

116116
use Symfony\Component\ClassLoader\ClassMapGenerator;
117117

118-
ClassMapGenerator::dump(array(__DIR__.'/library/bar', __DIR__.'/library/foo'), __DIR__.'/class_map.php');
118+
ClassMapGenerator::dump(
119+
array(__DIR__.'/library/bar', __DIR__.'/library/foo'),
120+
__DIR__.'/class_map.php'
121+
);
119122

120123
.. _`PSR-0`: http://www.php-fig.org/psr/psr-0
121124
.. _`PSR-4`: http://www.php-fig.org/psr/psr-4

components/config/definition.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ By changing a string value into an associative array with ``name`` as the key::
496496
->arrayNode('connection')
497497
->beforeNormalization()
498498
->ifString()
499-
->then(function($v) { return array('name'=> $v); })
499+
->then(function ($v) { return array('name' => $v); })
500500
->end()
501501
->children()
502502
->scalarNode('name')->isRequired()

components/console/helpers/dialoghelper.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ this set the seventh argument to ``true``::
230230
true // enable multiselect
231231
);
232232

233-
$selectedColors = array_map(function($c) use ($colors) {
233+
$selectedColors = array_map(function ($c) use ($colors) {
234234
return $colors[$c];
235235
}, $selected);
236236

components/console/introduction.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,11 @@ method::
466466

467467
$command = $application->find('demo:greet');
468468
$commandTester = new CommandTester($command);
469-
$commandTester->execute(
470-
array('command' => $command->getName(), 'name' => 'Fabien', '--iterations' => 5)
471-
);
469+
$commandTester->execute(array(
470+
'command' => $command->getName(),
471+
'name' => 'Fabien',
472+
'--iterations' => 5,
473+
));
472474

473475
$this->assertRegExp('/Fabien/', $commandTester->getDisplay());
474476
}

contributing/code/core_team.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ Active Core Members
5757
* **Christophe Coevoet** (:merger:`stof`) can merge into the BrowserKit_,
5858
Config_, Console_, DependencyInjection_, DomCrawler_, EventDispatcher_,
5959
HttpFoundation_, HttpKernel_, Serializer_, Stopwatch_, DoctrineBridge_,
60-
MonologBridge_, and TwigBridge_ components.
60+
MonologBridge_, and TwigBridge_ components;
61+
62+
* **Kévin Dunglas** (:merger:`dunglas`) can merge into the Serializer_
63+
component.
6164

6265
* **Deciders** (``@symfony/deciders`` on GitHub):
6366

cookbook/configuration/external_parameters.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,6 @@ You can now reference these parameters wherever you need them.
9898
)
9999
));
100100
101-
.. note::
102-
103-
Even in debug mode, setting or changing an environment variable
104-
requires your cache to be cleared to make the parameter available.
105-
In debug mode, this is required since only a change to a configuration
106-
file that is loaded by Symfony triggers your configuration to be
107-
re-evaluated.
108-
109101
Constants
110102
---------
111103

cookbook/email/email.rst

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,36 @@ How to Send an Email
77
Sending emails is a classic task for any web application and one that has
88
special complications and potential pitfalls. Instead of recreating the wheel,
99
one solution to send emails is to use the SwiftmailerBundle, which leverages
10-
the power of the `Swift Mailer`_ library.
11-
12-
.. note::
13-
14-
Don't forget to enable the bundle in your kernel before using it::
15-
16-
public function registerBundles()
17-
{
18-
$bundles = array(
19-
// ...
20-
21-
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
22-
);
23-
24-
// ...
25-
}
10+
the power of the `Swift Mailer`_ library. This bundle comes with the Symfony
11+
Standard Edition.
2612

2713
.. _swift-mailer-configuration:
2814

2915
Configuration
3016
-------------
3117

32-
Before using Swift Mailer, be sure to include its configuration. The only
33-
mandatory configuration parameter is ``transport``:
18+
To use Swift Mailer, you'll need to configure it for your mail server.
19+
20+
.. tip::
21+
22+
Instead of setting up/using your own mail server, you may want to use
23+
a hosted mail provider such as `Mandrill`_, `SendGrid`_, `Amazon SES`_
24+
or others. These give you an SMTP server, username and password (sometimes
25+
called keys) that can be used with the Swift Mailer configuration.
26+
27+
In a standard Symfony installation, some ``swiftmailer`` configuration is
28+
already included:
3429

3530
.. configuration-block::
3631

3732
.. code-block:: yaml
3833
3934
# app/config/config.yml
4035
swiftmailer:
41-
transport: smtp
42-
encryption: ssl
43-
auth_mode: login
44-
host: smtp.gmail.com
45-
username: your_username
46-
password: your_password
36+
transport: "%mailer_transport%"
37+
host: "%mailer_host%"
38+
username: "%mailer_user%"
39+
password: "%mailer_password%"
4740
4841
.. code-block:: xml
4942
@@ -55,27 +48,24 @@ mandatory configuration parameter is ``transport``:
5548
-->
5649
5750
<swiftmailer:config
58-
transport="smtp"
59-
encryption="ssl"
60-
auth-mode="login"
61-
host="smtp.gmail.com"
62-
username="your_username"
63-
password="your_password" />
51+
transport="%mailer_transport%"
52+
host="%mailer_host%"
53+
username="%mailer_user%"
54+
password="%mailer_password%" />
6455
6556
.. code-block:: php
6657
6758
// app/config/config.php
6859
$container->loadFromExtension('swiftmailer', array(
69-
'transport' => "smtp",
70-
'encryption' => "ssl",
71-
'auth_mode' => "login",
72-
'host' => "smtp.gmail.com",
73-
'username' => "your_username",
74-
'password' => "your_password",
60+
'transport' => "%mailer_transport%",
61+
'host' => "%mailer_host%",
62+
'username' => "%mailer_user%",
63+
'password' => "%mailer_password%",
7564
));
7665
77-
The majority of the Swift Mailer configuration deals with how the messages
78-
themselves should be delivered.
66+
These values (e.g. ``%mailer_transport%``), are reading from the parameters
67+
that are set in the :ref:`parameters.yml <config-parameters.yml>` file. You
68+
can modify the values in that file, or set the values directly here.
7969

8070
The following configuration attributes are available:
8171

@@ -105,15 +95,27 @@ an email is pretty straightforward::
10595
{
10696
$mailer = $this->get('mailer');
10797
$message = $mailer->createMessage()
108-
->setSubject('Hello Email')
98+
->setSubject('You have Completed Registration!')
10999
->setFrom('[email protected]')
110100
->setTo('[email protected]')
111101
->setBody(
112102
$this->renderView(
113-
'HelloBundle:Hello:email.txt.twig',
103+
// app/Resources/views/Emails/registration.html.twig
104+
'Emails/registration.html.twig',
105+
array('name' => $name)
106+
),
107+
'text/html'
108+
)
109+
/*
110+
* If you also want to include a plaintext version of the message
111+
->addPart(
112+
$this->renderView(
113+
'Emails/registration.txt.twig',
114114
array('name' => $name)
115-
)
115+
),
116+
'text/plain'
116117
)
118+
*/
117119
;
118120
$mailer->send($message);
119121

@@ -138,3 +140,6 @@ of `Creating Messages`_ in great detail in its documentation.
138140

139141
.. _`Swift Mailer`: http://swiftmailer.org/
140142
.. _`Creating Messages`: http://swiftmailer.org/docs/messages.html
143+
.. _`Mandrill`: https://mandrill.com/
144+
.. _`SendGrid`: https://sendgrid.com/
145+
.. _`Amazon SES`: http://aws.amazon.com/ses/

cookbook/routing/method_parameters.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ delete it by matching on GET, PUT and DELETE.
1818
blog_show:
1919
path: /blog/{slug}
2020
defaults: { _controller: AppBundle:Blog:show }
21-
methods: [GET]
21+
methods: [GET]
2222
2323
blog_update:
2424
path: /blog/{slug}
2525
defaults: { _controller: AppBundle:Blog:update }
26-
methods: [PUT]
26+
methods: [PUT]
2727
2828
blog_delete:
2929
path: /blog/{slug}
3030
defaults: { _controller: AppBundle:Blog:delete }
31-
methods: [DELETE]
31+
methods: [DELETE]
3232
3333
.. code-block:: xml
3434

cookbook/routing/slash_in_parameter.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ a more permissive regex path.
2424

2525
.. configuration-block::
2626

27+
.. code-block:: php-annotations
28+
29+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
30+
31+
class DemoController
32+
{
33+
/**
34+
* @Route("/hello/{name}", name="_hello", requirements={"name"=".+"})
35+
*/
36+
public function helloAction($name)
37+
{
38+
// ...
39+
}
40+
}
41+
2742
.. code-block:: yaml
2843
2944
_hello:
@@ -60,19 +75,4 @@ a more permissive regex path.
6075
6176
return $collection;
6277
63-
.. code-block:: php-annotations
64-
65-
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
66-
67-
class DemoController
68-
{
69-
/**
70-
* @Route("/hello/{name}", name="_hello", requirements={"name" = ".+"})
71-
*/
72-
public function helloAction($name)
73-
{
74-
// ...
75-
}
76-
}
77-
7878
That's it! Now, the ``{username}`` parameter can contain the ``/`` character.

cookbook/security/remember_me.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ remember me functionality, as it will not always be appropriate. The usual
6161
way of doing this is to add a checkbox to the login form. By giving the checkbox
6262
the name ``_remember_me``, the cookie will automatically be set when the checkbox
6363
is checked and the user successfully logs in. So, your specific login form
64-
might ultimately looks like this:
64+
might ultimately look like this:
6565

6666
.. configuration-block::
6767

cookbook/templating/twig_extension.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,18 @@ Now you must let the Service Container know about your newly created Twig Extens
7373
# app/config/services.yml
7474
services:
7575
app.twig_extension:
76-
class: AppBundle\Twig\AcmeExtension
76+
class: AppBundle\Twig\AppExtension
77+
public: false
7778
tags:
7879
- { name: twig.extension }
7980
8081
.. code-block:: xml
8182
8283
<!-- app/config/services.xml -->
8384
<services>
84-
<service id="app.twig_extension" class="AppBundle\Twig\AcmeExtension">
85+
<service id="app.twig_extension"
86+
class="AppBundle\Twig\AppExtension"
87+
public="false">
8588
<tag name="twig.extension" />
8689
</service>
8790
</services>
@@ -92,7 +95,8 @@ Now you must let the Service Container know about your newly created Twig Extens
9295
use Symfony\Component\DependencyInjection\Definition;
9396
9497
$container
95-
->register('app.twig_extension', '\AppBundle\Twig\AcmeExtension')
98+
->register('app.twig_extension', '\AppBundle\Twig\AppExtension')
99+
->setPublic(false)
96100
->addTag('twig.extension');
97101
98102
.. note::

reference/twig_reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ Global Variables
679679
app
680680
~~~
681681

682-
The ``app`` variable is available everywhere and gives access tomany commonly
682+
The ``app`` variable is available everywhere and gives access to many commonly
683683
needed objects and values. It is an instance of
684684
:class:`Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables`.
685685

0 commit comments

Comments
 (0)