Skip to content

path() explanation inside templating + Minor formatting changes #6218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions book/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1162,11 +1162,11 @@ each separated by a colon:

For example, a ``_controller`` value of ``AppBundle:Blog:show`` means:

========= ================== ==============
Bundle Controller Class Method Name
========= ================== ==============
AppBundle ``BlogController`` ``showAction``
========= ================== ==============
============= ================== ==============
Bundle Controller Class Method Name
============= ================== ==============
``AppBundle`` ``BlogController`` ``showAction``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a matter of consistency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree to make this change for the class name and method name. However, do we do the same with bundle names somewhere else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm usually against using literals for bundle names (as it's a name and not code). However, in this case, the table is used to explain the AppBundle:Blog:show logical name. I think it makes sense to put it in a literal, as it's just the logical name broken into 3 seperate pieces.

============= ================== ==============

The controller might look like this::

Expand Down Expand Up @@ -1461,7 +1461,7 @@ system. Take the ``blog_show`` example route from earlier::
// /blog/my-blog-post

To generate a URL, you need to specify the name of the route (e.g. ``blog_show``)
and any wildcards (e.g. ``slug = my-blog-post``) used in the path for that
and any wildcards (e.g. ``slug`` = ``my-blog-post``) used in the path for that
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we would like to point out the whole expression, so the = belongs to it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, it looks like an assignment operation. :)

route. With this information, any URL can easily be generated::

class MainController extends Controller
Expand Down Expand Up @@ -1500,7 +1500,7 @@ In an upcoming section, you'll learn how to generate URLs from inside templates.

var url = Routing.generate(
'blog_show',
{"slug": 'my-blog-post'}
{'slug': 'my-blog-post'}
);

For more information, see the documentation for that bundle.
Expand Down Expand Up @@ -1547,6 +1547,8 @@ a template helper function:
The ``path()`` PHP templating helper was introduced in Symfony 2.8. Prior
to 2.8, you had to use the ``generate()`` helper method.

The ``path()`` method generates relative URLs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should "blend" this into the paragraph before the code block, instead of a lost sentence somewhere at the end of the section. What about changing the paragraph to:

  The most common place to generate a URL is from within a template when linking
  between pages in your application. This is done just as before, but using
- a template helper function:
+ the ``path()`` function to generate a relative URI:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.


.. index::
single: Routing; Absolute URLs

Expand Down