8000 Merge branch '2.7' into 2.8 · symfony/symfony-docs@62af2ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 62af2ca

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: minor #7613 Twig Extensions Reference minor brush-up (mpdude) Update Title in controller.rst Update scheme.rst Update requirements.rst [#7845] minor tweaks Update translation_domain.rst.inc Update page_creation.rst to correct hidden colon Update forms.rst Minor reword Update deployment.rst KernelTestCase::createKernel() is static, $this->createKernel() -> static::createKernel() Better explain how to enable the validation component and its annotations Fix the link to ConEmu (it is now hosted on GitHub) Add annotation examples to match a route based on the host Minor reword to improve readability Minor reword and reformatting Add security stateless tip typo
2 parents a5ea888 + 2542b36 commit 62af2ca

15 files changed

+233
-35
lines changed

console.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ you can extend your test from
273273
{
274274
public function testExecute()
275275
{
276-
$kernel = $this->createKernel();
276+
$kernel = static::createKernel();
277277
$kernel->boot();
278278

279279
$application = new Application($kernel);

contributing/code/tests.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ what's going on and if the tests are broken because of the new code.
5555
to see colored test results.
5656

5757
.. _Cmder: http://cmder.net/
58-
.. _ConEmu: https://code.google.com/p/conemu-maximus5/
58+
.. _ConEmu: https://conemu.github.io/
5959
.. _ANSICON: https://github.com/adoxa/ansicon/releases
6060
.. _Mintty: https://mintty.github.io/

controller.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ The Symfony templating system and Twig are explained more in the
237237

238238
.. _controller-accessing-services:
239239

240-
Accessing other Services
240+
Accessing Other Services
241241
~~~~~~~~~~~~~~~~~~~~~~~~
242242

243243
Symfony comes packed with a lot of useful objects, called *services*. These

deployment.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ specifically tailored to the requirements of Symfony.
808 9E88 0
`Capistrano`_ with `Symfony plugin`_
8181
`Capistrano`_ is a remote server automation and deployment tool written in Ruby.
8282
`Symfony plugin`_ is a plugin to ease Symfony related tasks, inspired by `Capifony`_
83-
(which works only with Capistrano 2 )
83+
(which works only with Capistrano 2).
8484

8585
`sf2debpkg`_
8686
Helps you build a native Debian package for your Symfony project.
@@ -181,12 +181,12 @@ setup:
181181
* Pushing assets to a CDN
182182
* ...
183183

184-
Application Lifecycle: Continuous Integration, QA, etc
185-
------------------------------------------------------
184+
Application Lifecycle: Continuous Integration, QA, etc.
185+
-------------------------------------------------------
186186

187187
While this entry covers the technical details of deploying, the full lifecycle
188-
of taking code from development up to production may have a lot more steps
189-
(think deploying to staging, QA (Quality Assurance), running tests, etc).
188+
of taking code from development up to production may have more steps:
189+
deploying to staging, QA (Quality Assurance), running tests, etc.
190190

191191
The use of staging, testing, QA, continuous integration, database migrations
192192
and the capability to roll back in case of failure are all strongly advised. There

forms.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ to do with Symfony or any other library. It's quite simply a normal PHP object
6161
that directly solves a problem inside *your* application (i.e. the need to
6262
represent a task in your application). Of course, by the end of this article,
6363
you'll be able to submit data to a ``Task`` instance (via an HTML form), validate
64-
its data, and persist it to the database.
64+
its data and persist it to the database.
6565

6666
.. index::
6767
single: Forms; Create a form in a controller
@@ -116,7 +116,7 @@ from inside a controller::
116116

117117
Creating a form requires relatively little code because Symfony form objects
118118
are built with a "form builder". The form builder's purpose is to allow you
119-
to write simple form "recipes", and have it do all the heavy-lifting of actually
119+
to write simple form "recipes" and have it do all the heavy-lifting of actually
120120
building the form.
121121

122122
In this example, you've added two fields to your form - ``task`` and ``dueDate`` -
@@ -278,7 +278,7 @@ your controller::
278278
to the ``submit()`` method - a strategy which is deprecated and will be
279279
removed in Symfony 3.0. For details on that method, see :ref:`form-submit-request`.
280280

281-
This controller follows a common pattern for handling forms, and has three
281+
This controller follows a common pattern for handling forms and has three
282282
possible paths:
283283

284284
#. When initially loading the page in a browser, the form is created and

introduction/from_flat_php_to_symfony2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ on the requested URI::
370370
echo '<html><body><h1>Page Not Found</h1></body></html>';
371371
}
372372

373-
For organization, both controllers (formerly ``index.php`` and ``show.php``)
373+
For organization, both controllers (formerly ``/index.php`` and ``/index.php/show``)
374374
are now PHP functions and each has been moved into a separate file named ``controllers.php``::
375375

376376
// controllers.php

page_creation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ to creating a page?
7979
in its own section, including how to make *variable* URLs;
8080

8181
#. *Create a controller*: The method below the route - ``numberAction()`` - is called
82-
the *controller*: this is a function where *you* build the page and ultimately
82+
the *controller*. This is a function where *you* build the page and ultimately
8383
return a ``Response`` object. You'll learn more about :doc:`controllers </controller>`
8484
in their own section, including how to return JSON responses.
8585

reference/configuration/security.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,13 @@ multiple firewalls, the "context" could actually be shared:
661661
),
662662
));
663663
664+
.. note::
665+
666+
The firewall context key is stored in session, so every firewall using it
667+
must set its ``stateless`` option to ``false``. Otherwise, the context is
668+
ignored and you won't be able to authenticate on multiple firewalls at the
669+
same time.
670+
664671
HTTP-Digest Authentication
665672
--------------------------
666673

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
translation_domain
22
~~~~~~~~~~~~~~~~~~
33

4-
**type**: ``string`` **default**: ``messages``
F987 4+
**type**: ``string``, ``null`` or ``false`` **default**: ``null``
55

6-
This is the translation domain that will be used for any labels or options
7-
that are rendered for this field.
6+
This is the translation domain that will be used for any label or option
7+
that is rendered for this field. Use ``null`` to reuse the translation domain
8+
of the parent form (or the default domain of the translator for the root
9+
form). Use ``false`` to disable translations.

reference/twig_reference.rst

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,32 @@ Symfony Twig Extensions
77
=======================
88

99
Twig is the default template engine for Symfony. By itself, it already contains
10-
a lot of built-in functions, filters, tags and tests (learn more about them
11-
from the `Twig Reference`_).
10+
a lot of built-in functions, filters, tags and tests. You can learn more about
11+
them from the `Twig Reference`_.
1212

13-
Symfony adds custom extensions on top of Twig to integrate some components
14-
into the Twig templates. The following sections describe the custom
15-
:ref:`functions <reference-twig-functions>`, :ref:`filters <reference-twig-filters>`,
16-
:ref:`tags <reference-twig-tags>` and :ref:`tests <reference-twig-tests>`
17-
that are available when using the Symfony Core Framework.
13+
The Symfony framework adds quite a few extra :ref:`functions <reference-twig-functions>`,
14+
:ref:`filters <reference-twig-filters>`, :ref:`tags <reference-twig-tags>`
15+
and :ref:`tests <reference-twig-tests>` to seamlessly integrate the
16+
various Symfony components with Twig templates. The following sections
17+
describe these extra features.
1818

19-
There may also be tags in bundles you use that aren't listed here.
19+
.. tip::
20+
21+
  Technically, most of the extensions live in the `Twig Bridge`_. That code
22+
might give you some ideas when you need to write your own Twig extension
23+
as described in :doc:`/templating/twig_extension`.
24+
25+
.. note::
26+
27+
This reference only covers the Twig extensions provided by the Symfony
28+
framework. You are probably using some other bundles as well, and
29+
those might come with their own extensions not covered here.
30+
31+
.. tip::
32+
33+
  The `Twig Extensions repository`_ contains some additional Twig extensions
34+
that do not belong to the Twig core, so you might want to have a look at
35+
the `Twig Extensions documentation`_.
2036

2137
.. _reference-twig-functions:
2238

@@ -756,8 +772,11 @@ Symfony Standard Edition Extensions
756772
The Symfony Standard Edition adds some bundles to the Symfony Core Framework.
757773
Those bundles can have other Twig extensions:
758774

759-
* **Twig Extensions** includes some interesting extensions that do not belong
760-
to the Twig core. You can read more in `the official Twig Extensions documentation`_.
775+
* **Assetic** adds the ``{% stylesheets %}``, ``{% javascripts %}`` and
776+
``{% image %}`` tags. You can read more about them in
777+
:doc:`the Assetic Documentation </assetic/asset_management>`.
761778

762779
.. _`Twig Reference`: http://twig.sensiolabs.org/documentation#reference
763-
.. _`the official Twig Extensions documentation`: http://twig-extensions.readthedocs.io/
780+
.. _`Twig Extensions repository`: https://github.com/twigphp/Twig-extensions
781+
.. _`Twig Extensions documentation`: http://twig-extensions.readthedocs.io/en/latest/
782+
.. _`Twig Bridge`: https://github.com/symfony/symfony/tree/master/src/Symfony/Bridge/Twig/Extension

routing/hostname_pattern.rst

Lines changed: 139 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,33 @@ You can also match on the HTTP *host* of the incoming request.
88

99
.. configuration-block::
1010

11+
.. code-block:: php-annotations
12+
13+
// src/Acme/DemoBundle/Controller/MainController.php
14+
namespace Acme\DemoBundle\Controller;
15+
16+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
17+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
18+
19+
class MainController extends Controller
20+
{
21+
/**
22+
* @Route("/", name="mobile_homepage", host="m.example.com")
23+
*/
24+
public function mobileHomepageAction()
25+
{
26+
// ...
27+
}
28+
29+
/**
30+
* @Route("/", name="homepage")
31+
*/
32+
public function homepageAction()
33+
{
34+
// ...
35+
}
36+
}
37+
1138
.. code-block:: yaml
1239
1340
mobile_homepage:
@@ -63,12 +90,39 @@ you can use placeholders in your hostname:
6390

6491
.. configuration-block::
6592

93+
.. code-block:: php-annotations
94+
95+
// src/Acme/DemoBundle/Controller/MainController.php
96+
namespace Acme\DemoBundle\Controller;
97+
98+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
99+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
100+
101+
class MainController extends Controller
102+
{
103+
/**
104+
* @Route("/", name="projects_homepage", host="{project_name}.example.com")
105+
*/
106+
public function projectsHomepageAction()
107+
{
108+
// ...
109+
}
110+
111+
/**
112+
* @Route("/", name="homepage")
113+
*/
114+
public function homepageAction()
115+
{
116+
// ...
117+
}
118+
}
119+
66120
.. code-block:: yaml
67121
68122
projects_homepage:
69123
path: /
70124
host: "{project_name}.example.com"
71-
defaults: { _controller: AcmeDemoBundle:Main:mobileHomepage }
125+
defaults: { _controller: AcmeDemoBundle:Main:projectsHomepage }
72126
73127
homepage:
74128
path: /
@@ -83,7 +137,7 @@ you can use placeholders in your hostname:
83137
http://symfony.com/schema/routing/routing-1.0.xsd">
84138
85139
<route id="projects_homepage" path="/" host="{project_name}.example.com">
86-
<default key="_controller">AcmeDemoBundle:Main:mobileHomepage</default>
140+
<default key="_controller">AcmeDemoBundle:Main:projectsHomepage</default>
87141
</route>
88142
89143
<route id="homepage" path="/">
@@ -98,7 +152,7 @@ you can use placeholders in your hostname:
98152
99153
$collection = new RouteCollection();
100154
$collection->add('project_homepage', new Route('/', array(
101-
'_controller' => 'AcmeDemoBundle:Main:mobileHomepage',
155+
'_controller' => 'AcmeDemoBundle:Main:projectsHomepage',
102156
), array(), array(), '{project_name}.example.com'));
103157
104158
$collection->add('homepage', new Route('/', array(
@@ -113,6 +167,39 @@ instance, if you want to match both ``m.example.com`` and
113167

114168
.. configuration-block::
115169

170+
.. code-block:: php-annotations
171+
172+
// src/Acme/DemoBundle/Controller/MainController.php
173+
namespace Acme\DemoBundle\Controller;
174+
175+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
176+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
177+
178+
class MainController extends Controller
< 10000 code>179+
{
180+
/**
181+
* @Route(
182+
* "/",
183+
* name="mobile_homepage",
184+
* host="{subdomain}.example.com",
185+
* defaults={"subdomain"="m"},
186+
* requirements={"subdomain"="m|mobile"}
187+
* )
188+
*/
189+
public function mobileHomepageAction()
190+
{
191+
// ...
192+
}
193+
194+
/**
195+
* @Route("/", name="homepage")
196+
*/
197+
public function homepageAction()
198+
{
199+
// ...
200+
}
201+
}
202+
116203
.. code-block:: yaml
117204
118205
mobile_homepage:
@@ -173,6 +260,39 @@ instance, if you want to match both ``m.example.com`` and
173260

174261
.. configuration-block::
175262

263+
.. code-block:: php-annotations
264+
265+
// src/Acme/DemoBundle/Controller/MainController.php
266+
namespace Acme\DemoBundle\Controller;
267+
268+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
269+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
270+
271+
class MainController extends Controller
272+
{
273+
/**
274+
* @Route(
275+
* "/",
276+
* name="mobile_homepage",
277+
* host="m.{domain}",
278+
* defaults={"domain"="%domain%"},
279+
* requirements={"domain"="%domain%"}
280+
* )
281+
*/
282+
public function mobileHomepageAction()
283+
{
284+
// ...
285+
}
286+
287+
/**
288+
* @Route("/", name="homepage")
289+
*/
290+
public function homepageAction()
291+
{
292+
// ...
293+
}
294+
}
295+
176296
.. code-block:: yaml
177297
178298
mobile_homepage:
@@ -241,6 +361,22 @@ You can also set the host option on imported routes:
241361

242362
.. configuration-block::
243363

364+
.. code-block:: php-annotations
365+
366+
// src/Acme/HelloBundle/Controller/MainController.php
367+
namespace Acme\HelloBundle\Controller;
368+
369+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
370+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
371+
372+
/**
373+
* @Route(host="hello.example.com")
374+
*/
375+
class MainController extends Controller
376+
{
377+
// ...
378+
}
379+
244380
.. code-block:: yaml
245381
246382
acme_hello:

routing/requirements.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ a routing ``{wildcard}`` to only match some regular expression:
7575
Thanks to the ``\d+`` requirement (i.e. a "digit" of any length), ``/blog/2`` will
7676
match this route but ``/blog/some-string`` will *not* match.
7777

78-
.. sidebar:: Earlier Routes always Win
78+
.. sidebar:: Earlier Routes Always Win
7979

8080
Why would you ever care about requirements? If a request matches *two* routes,
8181
then the first route always wins. By adding requirements to the first route,

routing/scheme.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. index::
22
single: Routing; Scheme requirement
33

4-
How to Force Routes to always Use HTTPS or HTTP
4+
How to Force Routes to Always Use HTTPS or HTTP
55
===============================================
66

77
Sometimes, you want to secure some routes and be sure that they are always

0 commit comments

Comments
 (0)
0