Skip to content

Commit 39f6876

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: (26 commits) Fixing typo thanks to xabbuh Add missing comma in array Removed unneeded spaces Updated as per discussion Updated according to comment and changed to AppBundle Added configuration of the your_api_key_user_provider as user provider fixed typo (acme -> app) Fix code examples Fix typo: missing of Fix typo: missing space Fix typo: Fabien => World 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 ...
2 parents a57db5b + ddf9aa5 commit 39f6876

20 files changed

+191
-109
lines changed

best_practices/business-logic.rst

+4-1
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

+2
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

+5-2
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ By changing a string value into an associative array with ``name`` as the key::
500500
->arrayNode('connection')
501501
->beforeNormalization()
502502
->ifString()
503-
->then(function($v) { return array('name'=> $v); })
503+
->then(function ($v) { return array('name' => $v); })
504504
->end()
505505
->children()
506506
->scalarNode('name')->isRequired()

components/console/changing_default_command.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ This will print the following to the command line:
5151

5252
.. code-block:: text
5353
54-
Hello Fabien
54+
Hello World
5555
5656
.. tip::
5757

components/console/helpers/debug_formatter.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ display information that the program is started::
5151

5252
$output->writeln($debugFormatter->start(
5353
spl_object_hash($process),
54-
'Some process description')
55-
);
54+
'Some process description'
55+
));
5656

5757
$process->run();
5858

@@ -68,7 +68,7 @@ You can tweak the prefix using the third argument::
6868
spl_object_hash($process),
6969
'Some process description',
7070
'STARTED'
71-
);
71+
));
7272
// will output:
7373
// STARTED Some process description
7474

components/console/helpers/dialoghelper.rst

+1-1
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/helpers/questionhelper.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ option is the default one.
108108
If the user enters an invalid string, an error message is shown and the user
109109
is asked to provide the answer another time, until they enter a valid string
110110
or reach the maximum number of attempts. The default value for the maximum number
111-
of attempts is ``null``, which means infinite number attempts. You can define
111+
of attempts is ``null``, which means infinite number of attempts. You can define
112112
your own error message using
113113
:method:`Symfony\\Component\\Console\\Question\\ChoiceQuestion::setErrorMessage`.
114114

components/console/introduction.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,11 @@ method::
459459

460460
$command = $application->find('demo:greet');
461461
$commandTester = new CommandTester($command);
462-
$commandTester->execute(
463-
array('command' => $command->getName(), 'name' => 'Fabien', '--iterations' => 5)
464-
);
462+
$commandTester->execute(array(
463+
'command' => $command->getName(),
464+
'name' => 'Fabien',
465+
'--iterations' => 5,
466+
));
465467

466468
$this->assertRegExp('/Fabien/', $commandTester->getDisplay());
467469
}

components/expression_language/syntax.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ For example::
259259
$inGroup = $language->evaluate(
260260
'user.group in ["human_resources", "marketing"]',
261261
array(
262-
'user' => $user
262+
'user' => $user,
263263
)
264264
);
265265

components/var_dumper/introduction.rst

+11
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ current PHP SAPI:
6262
You'll also learn how to change the format or redirect the output to
6363
wherever you want.
6464

65+
.. tip::
66+
67+
In order to have the ``dump()`` function always available when running
68+
any PHP code, you can install it globally on your computer:
69+
70+
#. Run ``composer global require symfony/var-dumper``;
71+
#. Add ``auto_prepend_file = ${HOME}/.composer/vendor/autoload.php``
72+
to your ``php.ini`` file;
73+
#. From time to time, run ``composer global update`` to have the latest
74+
bug fixes.
75+
6576
DebugBundle and Twig Integration
6677
--------------------------------
6778

contributing/code/core_team.rst

+4-1
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

-8
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

+46-41
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('send@example.com')
110100
->setTo('recipient@example.com')
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

+3-3
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

+15-15
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.

0 commit comments

Comments
 (0)