Skip to content

Commit

Permalink
minor #6898 Fixes after tonight's merge round (wouterj)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.7 branch.

Discussion
----------

Fixes after tonight's merge round

Some fixes after the merged changes by @weaverryan last night. See the commit messages for more details about the changes.

Commits
-------

8e66547 [Console] Focus on framework users first in the guides
cf4022e [Routing] Some minor tweaks to the placeholder doc
296a0a0 [Templating] Fix odd/even cycle
bbef239 [Contributing] Minor grammar fix
  • Loading branch information
weaverryan committed Aug 21, 2016
2 parents 2628e54 + 8e66547 commit bb0d522
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 27 deletions.
21 changes: 11 additions & 10 deletions console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,21 +216,16 @@ console::
namespace Tests\AppBundle\Command;

use AppBundle\Command\CreateUserCommand;
use Symfony\Component\Console\Application;
// use this if you're in the Symfony Framework
//use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\CommandTester;

class CreateUserCommandTest extends \PHPUnit_Framework_TestCase
class CreateUserCommandTest extends KernelTestCase
{
public function testExecute()
{
$application = new Application();

// if you're in the Symfony framework, do this instead
// extend the KernelTestCase class
// self::bootKernel();
// $application = new Application(self::$kernel);
self::bootKernel();
$application = new Application(self::$kernel);

$application->add(new CreateUserCommand());

Expand Down Expand Up @@ -259,6 +254,12 @@ console::
You can also test a whole console application by using
:class:`Symfony\\Component\\Console\\Tester\\ApplicationTester`.

.. note::

When using the Console component in a standalone project, use
:class:`Symfony\\Component\\Console\\Application <Symfony\\Component\\Console\\Application>`
and extend the normal ``\PHPUnit_Framework_TestCase``.

To be able to use the fully set up service container for your console tests
you can extend your test from
:class:`Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase`::
Expand Down
4 changes: 2 additions & 2 deletions contributing/documentation/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ link displayed for Platform.sh service.
Build the Documentation Locally
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Alternatively you can build the documentation in your own computer for testing
Alternatively you can build the documentation on your own computer for testing
purposes following these steps:

#. Install `pip`_ as explained in the `pip installation`_ article.
#. Install `pip`_ as explained in the `pip installation`_ article;

#. Install `Sphinx`_ and `Sphinx Extensions for PHP and Symfony`_
(depending on your system, you may need to execute this command as root user):
Expand Down
33 changes: 19 additions & 14 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ expressions - see :doc:`/routing/requirements`.
Giving {placeholders} a Default Value
-------------------------------------

In the previous example, the ``blog_list`` has a path of ``/blog/{page}``. If the
user goes to ``/blog/1``, it will match. But if the user goes to ``/blog``, it will
**not** match. As soon as you add a ``{placeholder}`` to a route, it *must* have
a value.
In the previous example, the ``blog_list`` has a path of ``/blog/{page}``. If
the user visits ``/blog/1``, it will match. But if they visit ``/blog``, it
will **not** match. As soon as you add a ``{placeholder}`` to a route, it
*must* have a value.

So how can we make ``/blog_list`` once again match when the user goes to ``/blog``?
By adding a *default* value:
So how can you make ``blog_list`` once again match when the user visits
``/blog``? By adding a *default* value:

.. configuration-block::

Expand Down Expand Up @@ -309,6 +309,7 @@ By adding a *default* value:
<route id="blog_list" path="/blog/{page}">
<default key="_controller">AppBundle:Blog:list</default>
<default key="page">1</default>
<requirement key="page">\d+</requirement>
</route>
Expand All @@ -322,19 +323,23 @@ By adding a *default* value:
use Symfony\Component\Routing\Route;
$collection = new RouteCollection();
$collection->add('blog_list', new Route('/blog/{page}', array(
'_controller' => 'AppBundle:Blog:list',
'page' => 1,
), array(
'page' => '\d+'
)));
$collection->add('blog_list', new Route(
'/blog/{page}',
array(
'_controller' => 'AppBundle:Blog:list',
'page' => 1,
),
array(
'page' => '\d+'
)
));
// ...
return $collection;
Now, when the user goes to ``/blog``, the ``blog_list`` route will match and ``$page``
will default to a value of ``1``.
Now, when the user visits ``/blog``, the ``blog_list`` route will match and
``$page`` will default to a value of ``1``.

.. index::
single: Routing; Advanced example
Expand Down
2 changes: 1 addition & 1 deletion templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ with alternating ``odd``, ``even`` classes:
.. code-block:: html+twig

{% for i in 1..10 %}
<div class="{{ cycle(['odd', 'even'], i) }}">
<div class="{{ cycle(['even', 'odd'], i) }}">
<!-- some HTML here -->
</div>
{% endfor %}
Expand Down

0 comments on commit bb0d522

Please sign in to comment.