8000 Merge branch '2.1' · adrienbrault/symfony-docs@c926dae · GitHub
[go: up one dir, main page]

Skip to content

Commit c926dae

Browse files
committed
Merge branch '2.1'
Conflicts: reference/configuration/security.rst
2 parents 854bf0e + cae9f9f commit c926dae

25 files changed

+481
-297
lines changed

book/controller.rst

Lines changed: 4 additions & 0 deletions
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

Lines changed: 7 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ content:
436436
"symfony/symfony": "2.1.*"
437437
},
438438
"autoload": {
439-
"files": ["model.php","controller.php"]
439+
"files": ["model.php","controllers.php"]
440440
}
441441
}
442442
@@ -462,7 +462,7 @@ the HTTP response being returned. Use them to improve the blog:
462462

463463
<?php
464464
// index.php
465-
require_once 'vendor/bootstrap.php';
465+
require_once 'vendor/autoload.php';
466466

467467
use Symfony\Component\HttpFoundation\Request;
468468
use Symfony\Component\HttpFoundation\Response;
@@ -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

Lines changed: 6 additions & 0 deletions
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
@@ -1026,6 +1030,8 @@ Here is how you can configure the Symfony2 reverse proxy to support the
10261030

10271031
// ...
10281032
use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;
1033+
use Symfony\Component\HttpFoundation\Request;
1034+
use Symfony\Component\HttpFoundation\Response;
10291035

10301036
class AppCache extends HttpCache
10311037
{

book/http_fundamentals.rst

Lines changed: 4 additions & 0 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,8 @@ you're actually using the templating engine service. For example::
10861086

10871087
is equivalent to::
10881088

1089+
use Symfony\Component\HttpFoundation\Response;
1090+
10891091
$engine = $this->container->get('templating');
10901092
$content = $engine->render('AcmeArticleBundle:Article:index.html.twig');
10911093

book/translation.rst

Lines changed: 15 additions & 8 deletions
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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ method::
9696
'The name of the bundle should be suffixed with \'Bundle\''
9797
);
9898
}
99+
return $answer;
99100
},
100101
false,
101102
'AcmeDemoBundle'
@@ -113,8 +114,8 @@ This methods has 2 new arguments, the full signature is::
113114

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

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

0 commit comments

Comments
 (0)
0