Skip to content

Commit cae9f9f

Browse files
committed
Merge branch '2.0' into 2.1
2 parents 3a364b9 + d1a79dc commit cae9f9f

23 files changed

+453
-293
lines changed

book/controller.rst

+4
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@ that's responsible for generating the HTML (or other format) for the controller.
493493
The ``renderView()`` method renders a template and returns its content. The
494494
content from the template can be used to create a ``Response`` object::
495495

496+
use Symfony\Component\HttpFoundation\Response;
497+
496498
$content = $this->renderView(
497499
'AcmeHelloBundle:Hello:index.html.twig',
498500
array('name' => $name)
@@ -705,6 +707,8 @@ The only requirement for a controller is to return a ``Response`` object. The
705707
abstraction around the HTTP response - the text-based message filled with HTTP
706708
headers and content that's sent back to the client::
707709

710+
use Symfony\Component\HttpFoundation\Response;
711+
708712
// create a simple Response with a 200 status code (the default)
709713
$response = new Response('Hello '.$name, 200);
710714

book/doctrine.rst

+7-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ just a simple PHP class.
142142
.. tip::
143143

144144
Once you learn the concepts behind Doctrine, you can have Doctrine create
145-
this entity class for you:
145+
simple entity classes for you:
146146

147147
.. code-block:: bash
148148
@@ -315,6 +315,12 @@ for the ``Product`` class. This is a safe command - you can run it over and
315315
over again: it only generates getters and setters that don't exist (i.e. it
316316
doesn't replace your existing methods).
317317

318+
.. caution::
319+
320+
Keep in mind that Doctrine's entity generator produces simple getters/setters.
321+
You should check generated entities and adjust getter/setter logic to your own
322+
needs.
323+
318324
.. sidebar:: More about ``doctrine:generate:entities``
319325

320326
With the ``doctrine:generate:entities`` command you can:

book/forms.rst

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ user must be bound to the form. Add the following functionality to your
205205
controller::
206206

207207
// ...
208+
use Symfony\Component\HttpFoundation\Request;
208209

209210
public function newAction(Request $request)
210211
{

book/from_flat_php_to_symfony2.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ them for you. Here's the same sample application, now built in Symfony2::
582582
}
583583
}
584584

585-
The two controllers are still lightweight. Each uses the Doctrine ORM library
585+
The two controllers are still lightweight. Each uses the :doc:`Doctrine ORM library</book/doctrine>`
586586
to retrieve objects from the database and the ``Templating`` component to
587587
render a template and return a ``Response`` object. The list template is
588588
now quite a bit simpler:

book/http_cache.rst

+6
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ its creation more manageable::
310310

311311
// ...
312312

313+
use Symfony\Component\HttpFoundation\Response;
314+
313315
$response = new Response();
314316

315317
// mark the response as either public or private
@@ -650,6 +652,8 @@ Put another way, the less you do in your application to return a 304 response,
650652
the better. The ``Response::isNotModified()`` method does exactly that by
651653
exposing a simple and efficient pattern::
652654

655+
use Symfony\Component\HttpFoundation\Response;
656+
653657
public function showAction($articleSlug)
654658
{
655659
// Get the minimum information to compute
@@ -1010,6 +1014,8 @@ Here is how you can configure the Symfony2 reverse proxy to support the
10101014

10111015
// ...
10121016
use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;
1017+
use Symfony\Component\HttpFoundation\Request;
1018+
use Symfony\Component\HttpFoundation\Response;
10131019

10141020
class AppCache extends HttpCache
10151021
{

book/http_fundamentals.rst

+4
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ need to check the incoming URI and execute different parts of your code dependin
363363
on that value. This can get ugly quickly::
364364

365365
// index.php
366+
use Symfony\Component\HttpFoundation\Request;
367+
use Symfony\Component\HttpFoundation\Response;
366368
$request = Request::createFromGlobals();
367369
$path = $request->getPathInfo(); // the URI path being requested
368370

@@ -457,6 +459,8 @@ the ``AcmeDemoBundle:Main:contact`` string is a short syntax that points to a
457459
specific PHP method ``contactAction`` inside a class called ``MainController``::
458460

459461
// src/Acme/DemoBundle/Controller/MainController.php
462+
use Symfony\Component\HttpFoundation\Response;
463+
460464
class MainController
461465
{
462466
public function contactAction()

book/page_creation.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,8 @@ options of each feature.
802802
three formats (YAML, XML and PHP). Each has its own advantages and
803803
disadvantages. The choice of which to use is up to you:
804804

805-
* *YAML*: Simple, clean and readable;
805+
* *YAML*: Simple, clean and readable (learn more about yaml in
806+
* ":doc:`/components/yaml/yaml_format`");
806807

807808
* *XML*: More powerful than YAML at times and supports IDE autocompletion;
808809

book/templating.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,8 @@ you're actually using the templating engine service. For example::
10451045

10461046
is equivalent to::
10471047

1048+
use Symfony\Component\HttpFoundation\Response;
1049+
10481050
$engine = $this->container->get('templating');
10491051
$content = $engine->render('AcmeArticleBundle:Article:index.html.twig');
10501052

book/translation.rst

+15-8
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ of text (called a *message*), use the
9797
:method:`Symfony\\Component\\Translation\\Translator::trans` method. Suppose,
9898
for example, that you're translating a simple message from inside a controller::
9999

100+
// ...
101+
use Symfony\Component\HttpFoundation\Response;
102+
100103
public function indexAction()
101104
{
102105
$t = $this->get('translator')->trans('Symfony2 is great');
@@ -171,6 +174,9 @@ Message Placeholders
171174

172175
Sometimes, a message containing a variable needs to be translated::
173176

177+
// ...
178+
use Symfony\Component\HttpFoundation\Response;
179+
174180
public function indexAction($name)
175181
{
176182
$t = $this->get('translator')->trans('Hello '.$name);
@@ -184,14 +190,17 @@ will try to look up the exact message, including the variable portions
184190
for every possible iteration of the ``$name`` variable, you can replace the
185191
variable with a "placeholder"::
186192

193+
// ...
194+
use Symfony\Component\HttpFoundation\Response;
195+
187196
public function indexAction($name)
188197
{
189198
$t = $this->get('translator')->trans(
190199
'Hello %name%',
191200
array('%name%' => $name)
192201
);
193202

194-
new Response($t);
203+
return new Response($t);
195204
}
196205

197206
Symfony2 will now look for a translation of the raw message (``Hello %name%``)
@@ -786,9 +795,9 @@ texts* and complex expressions:
786795

787796
Using the translation tags or filters have the same effect, but with
788797
one subtle difference: automatic output escaping is only applied to
789-
variables translated using a filter. In other words, if you need to
790-
be sure that your translated variable is *not* output escaped, you must
791-
apply the raw filter after the translation filter:
798+
translations using a filter. In other words, if you need to be sure
799+
that your translated is *not* output escaped, you must apply the
800+
``raw`` filter after the translation filter:
792801

793802
.. code-block:: jinja
794803
@@ -799,11 +808,9 @@ texts* and complex expressions:
799808
800809
{% set message = '<h3>foo</h3>' %}
801810
802-
{# a variable translated via a filter is escaped by default #}
811+
{# strings and variables translated via a filter is escaped by default #}
803812
{{ message|trans|raw }}
804-
805-
{# but static strings are never escaped #}
806-
{{ '<h3>foo</h3>'|trans }}
813+
{{ '<h3>bar</h3>'|trans|raw }}
807814
808815
.. versionadded:: 2.1
809816
You can now set the translation domain for an entire Twig template with a

components/console/helpers/dialoghelper.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ method::
7272
'The name of the bundle should be suffixed with \'Bundle\''
7373
);
7474
}
75+
return $answer;
7576
},
7677
false,
7778
'AcmeDemoBundle'
@@ -89,8 +90,8 @@ This methods has 2 new arguments, the full signature is::
8990

9091
The ``$validator`` is a callback which handles the validation. It should
9192
throw an exception if there is something wrong. The exception message is displayed
92-
in the console, so it is a good practice to put some useful information
93-
in it.
93+
in the console, so it is a good practice to put some useful information in it. The callback
94+
function should also return the value of the user's input if the validation was successful.
9495

9596
You can set the max number of times to ask in the ``$attempts`` argument.
9697
If you reach this max number it will use the default value, which is given

components/dependency_injection/compilation.rst

+27-1
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,20 @@ processed when the container is compiled at which point the Extensions are loade
112112
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
113113

114114
$container = new ContainerBuilder();
115+
$container->registerExtension(new AcmeDemoExtension);
116+
115117
$loader = new YamlFileLoader($container, new FileLocator(__DIR__));
116118
$loader->load('config.yml');
117119

118-
$container->registerExtension(new AcmeDemoExtension);
119120
// ...
120121
$container->compile();
121122

123+
.. note::
124+
125+
When loading a config file that uses an extension alias as a key, the
126+
extension must already have been registered with the container builder
127+
or an exception will be thrown.
128+
122129
The values from those sections of the config files are passed into the first
123130
argument of the ``load`` method of the extension::
124131

@@ -239,6 +246,25 @@ but also load a secondary one only if a certain parameter is set::
239246
}
240247
}
241248

249+
.. note::
250+
251+
Just registering an extension with the container is not enough to get
252+
it included in the processed extensions when the container is compiled.
253+
Loading config which uses the extension's alias as a key as in the above
254+
examples will ensure it is loaded. The container builder can also be
255+
told to load it with its
256+
:method:`Symfony\\Component\\DependencyInjection\\ContainerBuilder::loadFromExtension`
257+
method::
258+
259+
use Symfony\Component\DependencyInjection\ContainerBuilder;
260+
261+
$container = new ContainerBuilder();
262+
$extension = new AcmeDemoExtension();
263+
$container->registerExtension($extension);
264+
$container->loadFromExtension($extension->getAlias());
265+
$container->compile();
266+
267+
242268
.. note::
243269

244270
If you need to manipulate the configuration loaded by an extension then

components/dependency_injection/definitions.rst

+9-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Getting and Setting Service Definitions
2828
There are also some helpful methods for
2929
working with the service definitions.
3030

31-
To find out if there is a definition for a service id::
31+
To find out if there is a definition for a service id::
3232

3333
$container->hasDefinition($serviceId);
3434

@@ -84,7 +84,7 @@ To get an array of the constructor arguments for a definition you can use::
8484

8585
or to get a single argument by its position::
8686

87-
$definition->getArgument($index);
87+
$definition->getArgument($index);
8888
//e.g. $definition->getArguments(0) for the first argument
8989

9090
You can add a new argument to the end of the arguments array using::
@@ -95,7 +95,7 @@ The argument can be a string, an array, a service parameter by using ``%paramete
9595
or a service id by using ::
9696

9797
use Symfony\Component\DependencyInjection\Reference;
98-
98+
9999
// ...
100100

101101
$definition->addArgument(new Reference('service_id'));
@@ -131,3 +131,9 @@ You can also replace any existing method calls with an array of new ones with::
131131

132132
$definition->setMethodCalls($methodCalls);
133133

134+
.. tip::
135+
136+
There are more examples of specific ways of working with definitions
137+
in the PHP code blocks of the configuration examples on pages such as
138+
:doc:`/components/dependency_injection/factories` and
139+
:doc:`/components/dependency_injection/parentservices`.

components/dependency_injection/introduction.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ If you do want to though then the container can call the setter method::
147147

148148
$container
149149
->register('newsletter_manager', 'NewsletterManager')
150-
->addMethodCall('setMailer', new Reference('mailer'));
150+
->addMethodCall('setMailer', array(new Reference('mailer')));
151151

152152
You could then get your ``newsletter_manager`` service from the container
153153
like this::
@@ -259,6 +259,6 @@ The ``newsletter_manager`` and ``mailer`` services can be set up using config fi
259259
260260
$container
261261
->register('newsletter_manager', 'NewsletterManager')
262-
->addMethodCall('setMailer', new Reference('mailer'));
262+
->addMethodCall('setMailer', array(new Reference('mailer')));
263263
264264
.. _Packagist: https://packagist.org/packages/symfony/dependency-injection

components/dom_crawler.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ The DomCrawler Component
99

1010
.. note::
1111

12-
While possible, the DomCrawler is not designed for manipulation of the
13-
DOM or re-dumping HTML/XML.
12+
While possible, the DomCrawler component is not designed for manipulation
13+
of the DOM or re-dumping HTML/XML.
1414

1515
Installation
1616
------------
@@ -177,7 +177,7 @@ and :phpclass:`DOMNode` objects:
177177
$crawler->addNode($node);
178178
$crawler->add($document);
179179
180-
.. note::
180+
.. sidebar:: Manipulating and Dumping a ``Crawler``
181181

182182
These methods on the ``Crawler`` are intended to initially populate your
183183
``Crawler`` and aren't intended to be used to further manipulate a DOM

components/map.rst.inc

+3-2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191

9292
* :doc:`/components/templating`
9393

94-
* **YAML**
94+
* :doc:`/components/yaml/index`
9595

96-
* :doc:`/components/yaml`
96+
* :doc:`/components/yaml/introduction`
97+
* :doc:`/components/yaml/yaml_format`

components/yaml/index.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Yaml
2+
====
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
introduction
8+
yaml_format

0 commit comments

Comments
 (0)