Skip to content

Commit cb8a2c6

Browse files
committed
Implemented suggestions
1 parent d6711fe commit cb8a2c6

File tree

7 files changed

+146
-136
lines changed

7 files changed

+146
-136
lines changed

CONTRIBUTING.md

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@ Contributing
33

44
First of all, **thank you** for contributing, **you are awesome**!
55

6-
Here are a few rules to follow in order to ease code reviews, and discussions before
7-
maintainers accept and merge your work.
6+
Here are a few rules to follow in order to ease code reviews, and discussions
7+
before maintainers accept and merge your work:
88

9-
You MUST follow the [PSR-1](http://www.php-fig.org/psr/1/) and
10-
[PSR-2](http://www.php-fig.org/psr/2/). If you don't know about any of them, you
11-
should really read the recommendations. Can't wait? Use the [PHP-CS-Fixer
12-
tool](http://cs.sensiolabs.org/).
13-
14-
You MUST run the test suite.
15-
16-
You MUST write (or update) unit tests.
17-
18-
You SHOULD write documentation.
9+
* You MUST follow the [PSR-1](http://www.php-fig.org/psr/1/) and
10+
[PSR-2](http://www.php-fig.org/psr/2/) recommendations. Use the [PHP-CS-Fixer
11+
tool](http://cs.sensiolabs.org/) to fix the syntax of your code automatically.
12+
* You MUST run the test suite.
13+
* You MUST write (or update) unit tests.
14+
* You SHOULD write documentation.
1915

2016
Please, write [commit messages that make
2117
sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html),
@@ -31,3 +27,52 @@ Also, while creating your Pull Request on GitHub, you MUST write a description
3127
which gives the context and/or explains why you are creating it.
3228

3329
Thank you!
30+
31+
Running tests
32+
-------------
33+
34+
Before running the test suite, execute the following Composer command to install
35+
the dependencies used by the bundle:
36+
37+
```bash
38+
$ composer install --dev
39+
```
40+
41+
Then, execute the tests executing:
42+
43+
```bash
44+
$ phpunit
45+
```
46+
47+
### JavaScript Test Suite
48+
49+
First, install [PhantomJS](http://phantomjs.org/) and then, execute this command:
50+
51+
```bash
52+
$ phantomjs Resources/js/run_jsunit.js Resources/js/router_test.html
53+
```
54+
55+
Compiling the JavaScript files
56+
------------------------------
57+
58+
> **NOTE**
59+
>
60+
> We already provide a compiled version of the JavaScript; this section is only
61+
> relevant if you want to make changes to this script.
62+
63+
In order to re-compile the JavaScript source files that we ship with this
64+
bundle, you need the Google Closure Tools. You need the
65+
[plovr](http://plovr.com/download.html) tool, which is a Java ARchive, so you
66+
also need a working Java environment. You can re-compile the JavaScript with the
67+
following command:
68+
69+
```bash
70+
$ java -jar plovr.jar build Resources/config/plovr/compile.js
71+
```
72+
73+
Alternatively, you can use the JMSGoogleClosureBundle. If you install this
74+
bundle, you can re-compile the JavaScript with the following command:
75+
76+
```bash
77+
$ php app/console plovr:build @FOSJsRoutingBundle/compile.js
78+
```

Resources/doc/commands.rst

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Commands
2+
========
3+
4+
fos:js-routing:dump
5+
-------------------
6+
7+
This command dumps the route information into a file so that instead of having
8+
the controller generated JavaScript, you can use a normal file. This also allows
9+
to combine the routes with the other JavaScript files in assetic.
10+
11+
.. code-block:: bash
12+
13+
$ php app/console fos:js-routing:dump
14+
15+
Instead of the line
16+
17+
.. code-block:: twig
18+
19+
<script src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script>
20+
21+
you now include this as
22+
23+
.. code-block:: html
24+
25+
<script src="/js/fos_js_routes.js"></script>
26+
27+
Or inside assetic, do
28+
29+
.. code-block:: twig
30+
31+
{% javascripts filter='?yui_js'
32+
'bundles/fosjsrouting/js/router.js'
33+
'js/fos_js_routes.js'
34+
%}
35+
<script src="{{ asset_url }}"></script>
36+
{% endjavascripts %}
37+
38+
.. caution::
39+
40+
You should follow the Symfony documentation about generating URLs
41+
in the console: `Configuring The Request Context Globally`_.
42+
43+
.. tip::
44+
45+
If you are using JMSI18nRoutingBundle, you need to run the command with the
46+
``--locale`` parameter once for each locale you use and adjust your include
47+
paths accordingly.
48+
49+
fos:js-routing:debug
50+
--------------------
51+
52+
This command lists all exposed routes:
53+
54+
.. code-block:: bash
55+
56+
$ php app/console fos:js-routing:debug [name]
57+
58+
.. _`Configuring The Request Context Globally`: http://symfony.com/doc/current/cookbook/console/sending_emails.html#configuring-the-request-context-globally

Resources/doc/compiling.rst

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

Resources/doc/index.md

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

Resources/doc/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ relative or absolute URLs in the browser using the same routes as in the backend
99

1010
installation
1111
usage
12-
compilling
13-
testing
12+
commands

Resources/doc/testing.rst

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

Resources/doc/usage.rst

Lines changed: 30 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ Usage
33

44
Add these two lines in your layout:
55

6-
.. code-block:: twig
6+
.. configuration-block::
7+
8+
.. code-block:: html+twig
9+
10+
<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
11+
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>
12+
13+
.. code-block:: html+php
714

8-
<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
9-
<script src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script>
15+
<script src="<?php echo $view['assets']->getUrl('bundles/fosjsrouting/js/router.js') ?>"></script>
16+
<script src="<?php echo $view['router']->generate('fos_js_routing_js', array('callback' => 'fos.Router.setData')) ?>"></script>
1017

1118
.. note::
1219

@@ -20,39 +27,52 @@ It's as simple as calling:
2027

2128
.. code-block:: javascript
2229
23-
Routing.generate('route_id', /* your params */)
30+
Routing.generate('route_name', /* your params */)
2431
2532
Or if you want to generate **absolute URLs**:
2633

2734
.. code-block:: javascript
2835
29-
Routing.generate('route_id', /* your params */, true)
36+
Routing.generate('route_name', /* your params */, true)
3037
3138
Assuming some route definitions:
3239

3340
.. configuration-block::
3441

3542
.. code-block:: php-annotations
3643
37-
// src/Acme/DemoBundle/Controller/DefaultController.php
44+
// src/AppBundle/Controller/DefaultController.php
3845
3946
/**
40-
* @Route("/foo/{id}/bar", name="my_route_to_expose", options={"expose"=true})
47+
* @Route("/foo/{id}/bar", options={"expose"=true}, name="my_route_to_expose")
4148
*/
42-
public function exposedAction($foo)
49+
public function indexAction($foo) {
50+
// ...
51+
}
52+
53+
/**
54+
* @Route("/blog/{page}",
55+
* defaults = { "page" = 1 },
56+
* options = { "expose" = true },
57+
* name = "my_route_to_expose_with_defaults",
58+
* )
59+
*/
60+
public function blogAction($page) {
61+
// ...
62+
}
4363
4464
.. code-block:: yaml
4565
4666
# app/config/routing.yml
4767
my_route_to_expose:
4868
pattern: /foo/{id}/bar
49-
defaults: { _controller: HelloBundle:Hello:index }
69+
defaults: { _controller: AppBundle:Default:index }
5070
options:
5171
expose: true
5272
5373
my_route_to_expose_with_defaults:
5474
pattern: /blog/{page}
55-
defaults: { _controller: AcmeBlogBundle:Blog:index, page: 1 }
75+
defaults: { _controller: AppBundle:Default:blog, page: 1 }
5676
options:
5777
expose: true
5878
@@ -119,62 +139,3 @@ You can enable HTTP caching as below:
119139
smaxage: null # integer value, e.g. 300
120140
expires: null # anything that can be fed to "new \DateTime($expires)", e.g. "5 minutes"
121141
vary: [] # string or array, e.g. "Cookie" or [ Cookie, Accept ]
122-
123-
Commands
124-
--------
125-
126-
fos:js-routing:dump
127-
~~~~~~~~~~~~~~~~~~~
128-
129-
This command dumps the route information into a file so that instead of having
130-
the controller generated JavaScript, you can use a normal file. This also allows
131-
to combine the routes with the other JavaScript files in assetic.
132-
133-
.. code-block:: bash
134-
135-
$ php app/console fos:js-routing:dump
136-
137-
Instead of the line
138-
139-
.. code-block:: twig
140-
141-
<script src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script>
142-
143-
you now include this as
144-
145-
.. code-block:: html
146-
147-
<script src="/js/fos_js_routes.js"></script>
148-
149-
Or inside assetic, do
150-
151-
.. code-block:: twig
152-
153-
{% javascripts filter='?yui_js'
154-
'bundles/fosjsrouting/js/router.js'
155-
'js/fos_js_routes.js'
156-
%}
157-
<script src="{{ asset_url }}"></script>
158-
{% endjavascripts %}
159-
160-
.. caution::
161-
162-
You should follow the Symfony documentation about generating URLs
163-
in the console: `Configuring The Request Context Globally`_.
164-
165-
.. tip::
166-
167-
If you are using JMSI18nRoutingBundle, you need to run the command with the
168-
``--locale`` parameter once for each locale you use and adjust your include
169-
paths accordingly.
170-
171-
fos:js-routing:debug
172-
~~~~~~~~~~~~~~~~~~~~
173-
174-
This command lists all exposed routes:
175-
176-
.. code-block:: bash
177-
178-
$ php app/console fos:js-routing:debug [name]
179-
180-
.. _`Configuring The Request Context Globally`: http://symfony.com/doc/current/cookbook/console/sending_emails.html#configuring-the-request-context-globally

0 commit comments

Comments
 (0)