Skip to content

Commit 7bfe65d

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: Added a missing <script> tag in an example fixing index problem now that there were *no* frontend articles on 2.7 Removing bower, as even they now recommend to use yarn and webpack minor tweak Changed link to Capifony Fix comment to be consistent with the example Reworded the article about slashes in routing placeholders Minor reword of code contribution standards
2 parents ab9d44a + f5fb157 commit 7bfe65d

File tree

8 files changed

+41
-185
lines changed

8 files changed

+41
-185
lines changed

_build/redirection_map

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
/cookbook/form/inherit_data_option /form/inherit_data_option
164164
/cookbook/form/unit_testing /form/unit_testing
165165
/cookbook/form/use_empty_data /form/use_empty_data
166-
/cookbook/frontend/bower /frontend/bower
166+
/cookbook/frontend/bower /frontend
167167
/cookbook/frontend/index /frontend
168168
/cookbook/install/unstable_versions /setup/unstable_versions
169169
/cookbook/install/bundles /setup/bundles

contributing/code/standards.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Naming Conventions
186186
* Use camelCase, not underscores, for variable, function and method
187187
names, arguments;
188188

189-
* Use underscores for option names and parameter names;
189+
* Use underscores for configuration options and parameters;
190190

191191
* Use namespaces for all classes;
192192

deployment.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Don't forget that deploying your application also involves updating any dependen
197197
(typically via Composer), migrating your database, clearing your cache and
198198
other potential things like pushing assets to a CDN (see `Common Post-Deployment Tasks`_).
199199

200-
.. _`Capifony`: http://capifony.org/
200+
.. _`Capifony`: https://github.com/everzet/capifony
201201
.. _`Capistrano`: http://capistranorb.com/
202202
.. _`sf2debpkg`: https://github.com/liip/sf2debpkg
203203
.. _`Fabric`: http://www.fabfile.org/

form/type_guesser.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ With this knowledge, you can easily implement the ``guessType()`` method of the
140140
$phpdoc = $reflectionProperty->getDocComment();
141141

142142
// parse the $phpdoc into an array like:
143-
// array('type' => 'string', 'since' => '1.0')
143+
// array('var' => 'string', 'since' => '1.0')
144144
$phpdocTags = ...;
145145

146146
return $phpdocTags;

frontend.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
Front-end
22
=========
33

4-
.. toctree::
5-
:maxdepth: 1
6-
:glob:
4+
See the latest version of the docs for frontend tools. Or, see
5+
:doc:`/assetic`.
76

8-
frontend/*

frontend/bower.rst

Lines changed: 0 additions & 152 deletions
This file was deleted.

routing/generate_url_javascript.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ variables. The ``escape()`` function helps escape any non-JavaScript-safe values
3030
But if you *actually* need to generate routes in pure JavaScript, consider using
3131
the `FOSJsRoutingBundle`_. It makes the following possible:
3232

33-
.. code-block:: javascript
33+
.. code-block:: html+twig
3434

35+
<script>
3536
var url = Routing.generate('blog_show', {
3637
'slug': 'my-blog-post'
3738
});
39+
</script>
3840

3941
.. _`FOSJsRoutingBundle`: https://github.com/FriendsOfSymfony/FOSJsRoutingBundle

routing/slash_in_parameter.rst

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,47 @@ How to Allow a "/" Character in a Route Parameter
55
=================================================
66

77
Sometimes, you need to compose URLs with parameters that can contain a slash
8-
``/``. For example, take the classic ``/hello/{username}`` route. By default,
9-
``/hello/Fabien`` will match this route but not ``/hello/Fabien/Kris``. This
10-
is because Symfony uses this character as separator between route parts.
8+
``/``. For example, consider the ``/share/{token}`` route. If the ``token``
9+
value contains a ``/`` character this route won't match. This is because Symfony
10+
uses this character as separator between route parts.
1111

12-
This guide covers how you can modify a route so that ``/hello/Fabien/Kris``
13-
matches the ``/hello/{username}`` route, where ``{username}`` equals ``Fabien/Kris``.
12+
This article explains how you can modify a route definition so that placeholders
13+
can contain the ``/`` character too.
1414

1515
Configure the Route
1616
-------------------
1717

18-
By default, the Symfony Routing component requires that the parameters
19-
match the following regex path: ``[^/]+``. This means that all characters
20-
are allowed except ``/``.
18+
By default, the Symfony Routing component requires that the parameters match
19+
the following regular expression: ``[^/]+``. This means that all characters are
20+
allowed except ``/``.
2121

22-
You must explicitly allow ``/`` to be part of your parameter by specifying
23-
a more permissive regex path.
22+
You must explicitly allow ``/`` to be part of your placeholder by specifying
23+
a more permissive regular expression for it:
2424

2525
.. configuration-block::
2626

2727
.. code-block:: php-annotations
2828
2929
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
3030
31-
class DemoController
31+
class DefaultController
3232
{
3333
/**
34-
* @Route("/hello/{username}", name="_hello", requirements={"username"=".+"})
34+
* @Route("/share/{token}", name="share", requirements={"token"=".+"})
3535
*/
36-
public function helloAction($username)
36+
public function shareAction($token)
3737
{
3838
// ...
3939
}
4040
}
4141
4242
.. code-block:: yaml
4343
44-
_hello:
45-
path: /hello/{username}
46-
defaults: { _controller: AppBundle:Demo:hello }
44+
share:
45+
path: /share/{token}
46+
defaults: { _controller: AppBundle:Default:share }
4747
requirements:
48-
username: .+
48+
token: .+
4949
5050
.. code-block:: xml
5151
@@ -55,9 +55,9 @@ a more permissive regex path.
5555
xsi:schemaLocation="http://symfony.com/schema/routing
5656
http://symfony.com/schema/routing/routing-1.0.xsd">
5757
58-
<route id="_hello" path="/hello/{username}">
59-
<default key="_controller">AppBundle:Demo:hello</default>
60-
<requirement key="username">.+</requirement>
58+
<route id="share" path="/share/{token}">
59+
<default key="_controller">AppBundle:Default:share</default>
60+
<requirement key="token">.+</requirement>
6161
</route>
6262
</routes>
6363
@@ -67,12 +67,20 @@ a more permissive regex path.
6767
use Symfony\Component\Routing\Route;
6868
6969
$collection = new RouteCollection();
70-
$collection->add('_hello', new Route('/hello/{username}', array(
71-
'_controller' => 'AppBundle:Demo:hello',
70+
$collection->add('share', new Route('/share/{token}', array(
71+
'_controller' => 'AppBundle:Default:share',
7272
), array(
73-
'username' => '.+',
73+
'token' => '.+',
7474
)));
7575
7676
return $collection;
7777
78-
That's it! Now, the ``{username}`` parameter can contain the ``/`` character.
78+
That's it! Now, the ``{token}`` parameter can contain the ``/`` character.
79+
80+
.. note::
81+
82+
If the route defines several placeholders and you apply this permissive
83+
regular expression to all of them, the results won't be the expected. For
84+
example, if the route definition is ``/share/{path}/{token}`` and both
85+
``path`` and ``token`` accept ``/``, then ``path`` will contain its contents
86+
and the token, and ``token`` will be empty.

0 commit comments

Comments
 (0)