Permalink
Browse files

feature #4740 Use AppBundle whenever it's possible (javiereguiluz)

This PR was merged into the 2.3 branch.

Discussion
----------

Use AppBundle whenever it's possible

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.3+
| Fixed tickets | -

This PR replaces `AcmeFooBundle`, `AcmeHelloBundle` and `AcmeDemoBundle` by `AppBundle` whenever it's possible in the Cookbook.

This is the first step into making the cookbook compliant with the recent good practices promoted by Symfony (the book is being made compliant in #4431). If we change everything to comply with the good practices, the pull request will be massive and it will take months. That's why I think it's better to do it in several steps using different pull requests.

By the way, this PR also contains some minor tweaks about using the new `app/config/services.yml` file. I can revert those changes if you want it.

Commits
-------

c6580f8 Use AppBundle whenever it's possible
  • Loading branch information...
weaverryan committed Jan 16, 2015
2 parents 5940d52 + c6580f8 commit 528e8e14aa690bf761d5ad4fa763593f856c6afb
Showing with 534 additions and 530 deletions.
  1. +12 −12 cookbook/assetic/apply_to_option.rst
  2. +33 −33 cookbook/assetic/asset_management.rst
  3. +3 −3 cookbook/assetic/jpeg_optimize.rst
  4. +7 −7 cookbook/assetic/uglifyjs.rst
  5. +7 −7 cookbook/assetic/yuicompressor.rst
  6. +3 −2 cookbook/bundles/extension.rst
  7. +6 −6 cookbook/configuration/apache_router.rst
  8. +5 −5 cookbook/console/console_command.rst
  9. +12 −12 cookbook/console/logging.rst
  10. +1 −1 cookbook/console/sending_emails.rst
  11. +5 −5 cookbook/controller/error_pages.rst
  12. +29 −29 cookbook/controller/service.rst
  13. +12 −12 cookbook/doctrine/custom_dql_functions.rst
  14. +6 −6 cookbook/doctrine/dbal.rst
  15. +10 −10 cookbook/doctrine/file_uploads.rst
  16. +4 −4 cookbook/doctrine/multiple_entity_managers.rst
  17. +1 −1 cookbook/email/testing.rst
  18. +22 −22 cookbook/event_dispatcher/before_after_filters.rst
  19. +22 −22 cookbook/form/create_custom_field_type.rst
  20. +33 −33 cookbook/form/dynamic_form_modification.rst
  21. +22 −22 cookbook/form/form_customization.rst
  22. +14 −14 cookbook/form/inherit_data_option.rst
  23. +2 −2 cookbook/form/use_empty_data.rst
  24. +14 −11 cookbook/profiler/matchers.rst
  25. +12 −12 cookbook/request/mime_type.rst
  26. +3 −3 cookbook/routing/extra_information.rst
  27. +9 −9 cookbook/routing/method_parameters.rst
  28. +5 −8 cookbook/routing/redirect_in_config.rst
  29. +5 −5 cookbook/routing/redirect_trailing_slash.rst
  30. +3 −3 cookbook/routing/scheme.rst
  31. +16 −16 cookbook/routing/service_container_parameters.rst
  32. +3 −3 cookbook/routing/slash_in_parameter.rst
  33. +3 −3 cookbook/security/acl.rst
  34. +23 −23 cookbook/security/custom_authentication_provider.rst
  35. +16 −16 cookbook/security/securing_services.rst
  36. +8 −8 cookbook/security/target_path.rst
  37. +5 −5 cookbook/security/voters.rst
  38. +12 −12 cookbook/security/voters_data_permission.rst
  39. +10 −10 cookbook/service_container/event_listener.rst
  40. +22 −22 cookbook/service_container/scopes.rst
  41. +8 −8 cookbook/session/locale_sticky_session.rst
  42. +25 −25 cookbook/templating/PHP.rst
  43. +4 −4 cookbook/templating/namespaced_paths.rst
  44. +7 −7 cookbook/templating/render_without_controller.rst
  45. +11 −11 cookbook/templating/twig_extension.rst
  46. +4 −4 cookbook/testing/database.rst
  47. +5 −5 cookbook/testing/simulating_authentication.rst
  48. +23 −20 cookbook/validation/custom_constraint.rst
  49. +7 −7 cookbook/web_services/php_soap_extension.rst
@@ -59,14 +59,14 @@ templates:
.. code-block:: html+jinja
{% javascripts '@AcmeFooBundle/Resources/public/js/example.coffee' filter='coffee' %}
{% javascripts '@AppBundle/Resources/public/js/example.coffee' filter='coffee' %}
<script src="{{ asset_url }}" type="text/javascript"></script>
{% endjavascripts %}
.. code-block:: html+php
<?php foreach ($view['assetic']->javascripts(
array('@AcmeFooBundle/Resources/public/js/example.coffee'),
array('@AppBundle/Resources/public/js/example.coffee'),
array('coffee')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>" type="text/javascript"></script>
@@ -84,8 +84,8 @@ You can also combine multiple CoffeeScript files into a single output file:
.. code-block:: html+jinja
{% javascripts '@AcmeFooBundle/Resources/public/js/example.coffee'
'@AcmeFooBundle/Resources/public/js/another.coffee'
{% javascripts '@AppBundle/Resources/public/js/example.coffee'
'@AppBundle/Resources/public/js/another.coffee'
filter='coffee' %}
<script src="{{ asset_url }}" type="text/javascript"></script>
{% endjavascripts %}
@@ -94,8 +94,8 @@ You can also combine multiple CoffeeScript files into a single output file:
<?php foreach ($view['assetic']->javascripts(
array(
'@AcmeFooBundle/Resources/public/js/example.coffee',
'@AcmeFooBundle/Resources/public/js/another.coffee',
'@AppBundle/Resources/public/js/example.coffee',
'@AppBundle/Resources/public/js/another.coffee',
),
array('coffee')
) as $url): ?>
@@ -170,19 +170,19 @@ being run through the CoffeeScript filter):
.. code-block:: html+jinja
{% javascripts '@AcmeFooBundle/Resources/public/js/example.coffee'
'@AcmeFooBundle/Resources/public/js/another.coffee'
'@AcmeFooBundle/Resources/public/js/regular.js' %}
{% javascripts '@AppBundle/Resources/public/js/example.coffee'
'@AppBundle/Resources/public/js/another.coffee'
'@AppBundle/Resources/public/js/regular.js' %}
<script src="{{ asset_url }}" type="text/javascript"></script>
{% endjavascripts %}
.. code-block:: html+php
<?php foreach ($view['assetic']->javascripts(
array(
'@AcmeFooBundle/Resources/public/js/example.coffee',
'@AcmeFooBundle/Resources/public/js/another.coffee',
'@AcmeFooBundle/Resources/public/js/regular.js',
'@AppBundle/Resources/public/js/example.coffee',
'@AppBundle/Resources/public/js/another.coffee',
'@AppBundle/Resources/public/js/regular.js',
)
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>" type="text/javascript"></script>
@@ -59,14 +59,14 @@ To include JavaScript files, use the ``javascripts`` tag in any template:
.. code-block:: html+jinja
{% javascripts '@AcmeFooBundle/Resources/public/js/*' %}
{% javascripts '@AppBundle/Resources/public/js/*' %}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
.. code-block:: html+php
<?php foreach ($view['assetic']->javascripts(
array('@AcmeFooBundle/Resources/public/js/*')
array('@AppBundle/Resources/public/js/*')
) as $url): ?>
<script type="text/javascript" src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach ?>
@@ -81,7 +81,7 @@ To include JavaScript files, use the ``javascripts`` tag in any template:
{# ... #}
{% block javascripts %}
{% javascripts '@AcmeFooBundle/Resources/public/js/*' %}
{% javascripts '@AppBundle/Resources/public/js/*' %}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}
@@ -92,7 +92,7 @@ To include JavaScript files, use the ``javascripts`` tag in any template:
You can also include CSS Stylesheets: see :ref:`cookbook-assetic-including-css`.
In this example, all of the files in the ``Resources/public/js/`` directory
of the ``AcmeFooBundle`` will be loaded and served from a different location.
of the ``AppBundle`` will be loaded and served from a different location.
The actual rendered tag might simply look like:
.. code-block:: html
@@ -115,14 +115,14 @@ above, except with the ``stylesheets`` tag:
.. code-block:: html+jinja
{% stylesheets 'bundles/acme_foo/css/*' filter='cssrewrite' %}
{% stylesheets 'bundles/app/css/*' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
.. code-block:: html+php
<?php foreach ($view['assetic']->stylesheets(
array('bundles/acme_foo/css/*'),
array('bundles/app/css/*'),
array('cssrewrite')
) as $url): ?>
<link rel="stylesheet" href="<?php echo $view->escape($url) ?>" />
@@ -138,7 +138,7 @@ above, except with the ``stylesheets`` tag:
{# ... #}
{% block stylesheets %}
{% stylesheets 'bundles/acme_foo/css/*' filter='cssrewrite' %}
{% stylesheets 'bundles/app/css/*' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% endblock %}
@@ -151,11 +151,11 @@ the :ref:`cssrewrite <cookbook-assetic-cssrewrite>` filter.
.. note::
Notice that in the original example that included JavaScript files, you
referred to the files using a path like ``@AcmeFooBundle/Resources/public/file.js``,
referred to the files using a path like ``@AppBundle/Resources/public/file.js``,
but that in this example, you referred to the CSS files using their actual,
publicly-accessible path: ``bundles/acme_foo/css``. You can use either, except
publicly-accessible path: ``bundles/app/css``. You can use either, except
that there is a known issue that causes the ``cssrewrite`` filter to fail
when using the ``@AcmeFooBundle`` syntax for CSS Stylesheets.
when using the ``@AppBundle`` syntax for CSS Stylesheets.
.. _cookbook-assetic-including-image:
@@ -168,14 +168,14 @@ To include an image you can use the ``image`` tag.
.. code-block:: html+jinja
{% image '@AcmeFooBundle/Resources/public/images/example.jpg' %}
{% image '@AppBundle/Resources/public/images/example.jpg' %}
<img src="{{ asset_url }}" alt="Example" />
{% endimage %}
.. code-block:: html+php
<?php foreach ($view['assetic']->image(
array('@AcmeFooBundle/Resources/public/images/example.jpg')
array('@AppBundle/Resources/public/images/example.jpg')
) as $url): ?>
<img src="<?php echo $view->escape($url) ?>" alt="Example" />
<?php endforeach ?>
@@ -198,7 +198,7 @@ You can see an example in the previous section.
.. caution::
When using the ``cssrewrite`` filter, don't refer to your CSS files using
the ``@AcmeFooBundle`` syntax. See the note in the above section for details.
the ``@AppBundle`` syntax. See the note in the above section for details.
Combining Assets
~~~~~~~~~~~~~~~~
@@ -215,7 +215,7 @@ but still serve them as a single file:
.. code-block:: html+jinja
{% javascripts
'@AcmeFooBundle/Resources/public/js/*'
'@AppBundle/Resources/public/js/*'
'@AcmeBarBundle/Resources/public/js/form.js'
'@AcmeBarBundle/Resources/public/js/calendar.js' %}
<script src="{{ asset_url }}"></script>
@@ -225,7 +225,7 @@ but still serve them as a single file:
<?php foreach ($view['assetic']->javascripts(
array(
'@AcmeFooBundle/Resources/public/js/*',
'@AppBundle/Resources/public/js/*',
'@AcmeBarBundle/Resources/public/js/form.js',
'@AcmeBarBundle/Resources/public/js/calendar.js',
)
@@ -254,17 +254,17 @@ combine third party assets, such as jQuery, with your own into a single file:
.. code-block:: html+jinja
{% javascripts
'@AcmeFooBundle/Resources/public/js/thirdparty/jquery.js'
'@AcmeFooBundle/Resources/public/js/*' %}
'@AppBundle/Resources/public/js/thirdparty/jquery.js'
'@AppBundle/Resources/public/js/*' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
.. code-block:: html+php
<?php foreach ($view['assetic']->javascripts(
array(
'@AcmeFooBundle/Resources/public/js/thirdparty/jquery.js',
'@AcmeFooBundle/Resources/public/js/*',
'@AppBundle/Resources/public/js/thirdparty/jquery.js',
'@AppBundle/Resources/public/js/*',
)
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
@@ -287,8 +287,8 @@ configuration under the ``assetic`` section. Read more in the
assets:
jquery_and_ui:
inputs:
- '@AcmeFooBundle/Resources/public/js/thirdparty/jquery.js'
- '@AcmeFooBundle/Resources/public/js/thirdparty/jquery.ui.js'
- '@AppBundle/Resources/public/js/thirdparty/jquery.js'
- '@AppBundle/Resources/public/js/thirdparty/jquery.ui.js'
.. code-block:: xml
@@ -299,8 +299,8 @@ configuration under the ``assetic`` section. Read more in the
<assetic:config>
<assetic:asset name="jquery_and_ui">
<assetic:input>@AcmeFooBundle/Resources/public/js/thirdparty/jquery.js</assetic:input>
<assetic:input>@AcmeFooBundle/Resources/public/js/thirdparty/jquery.ui.js</assetic:input>
<assetic:input>@AppBundle/Resources/public/js/thirdparty/jquery.js</assetic:input>
<assetic:input>@AppBundle/Resources/public/js/thirdparty/jquery.ui.js</assetic:input>
</assetic:asset>
</assetic:config>
</container>
@@ -312,8 +312,8 @@ configuration under the ``assetic`` section. Read more in the
'assets' => array(
'jquery_and_ui' => array(
'inputs' => array(
'@AcmeFooBundle/Resources/public/js/thirdparty/jquery.js',
'@AcmeFooBundle/Resources/public/js/thirdparty/jquery.ui.js',
'@AppBundle/Resources/public/js/thirdparty/jquery.js',
'@AppBundle/Resources/public/js/thirdparty/jquery.ui.js',
),
),
),
@@ -328,7 +328,7 @@ with the ``@named_asset`` notation:
{% javascripts
'@jquery_and_ui'
'@AcmeFooBundle/Resources/public/js/*' %}
'@AppBundle/Resources/public/js/*' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
@@ -337,7 +337,7 @@ with the ``@named_asset`` notation:
<?php foreach ($view['assetic']->javascripts(
array(
'@jquery_and_ui',
'@AcmeFooBundle/Resources/public/js/*',
'@AppBundle/Resources/public/js/*',
)
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
@@ -406,14 +406,14 @@ into your template:
.. code-block:: html+jinja
{% javascripts '@AcmeFooBundle/Resources/public/js/*' filter='uglifyjs2' %}
{% javascripts '@AppBundle/Resources/public/js/*' filter='uglifyjs2' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
.. code-block:: html+php
<?php foreach ($view['assetic']->javascripts(
array('@AcmeFooBundle/Resources/public/js/*'),
array('@AppBundle/Resources/public/js/*'),
array('uglifyjs2')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
@@ -432,14 +432,14 @@ done from the template and is relative to the public document root:
.. code-block:: html+jinja
{% javascripts '@AcmeFooBundle/Resources/public/js/*' output='js/compiled/main.js' %}
{% javascripts '@AppBundle/Resources/public/js/*' output='js/compiled/main.js' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
.. code-block:: html+php
<?php foreach ($view['assetic']->javascripts(
array('@AcmeFooBundle/Resources/public/js/*'),
array('@AppBundle/Resources/public/js/*'),
array(),
array('output' => 'js/compiled/main.js')
) as $url): ?>
@@ -555,14 +555,14 @@ some isolated directory (e.g. ``/js/compiled``), to keep things organized:
.. code-block:: html+jinja
{% javascripts '@AcmeFooBundle/Resources/public/js/*' output='js/compiled/main.js' %}
{% javascripts '@AppBundle/Resources/public/js/*' output='js/compiled/main.js' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
.. code-block:: html+php
<?php foreach ($view['assetic']->javascripts(
array('@AcmeFooBundle/Resources/public/js/*'),
array('@AppBundle/Resources/public/js/*'),
array(),
array('output' => 'js/compiled/main.js')
) as $url): ?>
@@ -57,15 +57,15 @@ It can now be used from a template:
.. code-block:: html+jinja
{% image '@AcmeFooBundle/Resources/public/images/example.jpg'
{% image '@AppBundle/Resources/public/images/example.jpg'
filter='jpegoptim' output='/images/example.jpg' %}
<img src="{{ asset_url }}" alt="Example"/>
{% endimage %}
.. code-block:: html+php
<?php foreach ($view['assetic']->image(
array('@AcmeFooBundle/Resources/public/images/example.jpg'),
array('@AppBundle/Resources/public/images/example.jpg'),
array('jpegoptim')
) as $url): ?>
<img src="<?php echo $view->escape($url) ?>" alt="Example"/>
@@ -204,7 +204,7 @@ The Twig template can now be changed to the following:
.. code-block:: html+jinja
<img src="{{ jpegoptim('@AcmeFooBundle/Resources/public/images/example.jpg') }}" alt="Example"/>
<img src="{{ jpegoptim('@AppBundle/Resources/public/images/example.jpg') }}" alt="Example"/>
You can specify the output directory in the config in the following way:
@@ -161,22 +161,22 @@ your assets are a part of the view layer, this work is done in your templates:
.. code-block:: html+jinja
{% javascripts '@AcmeFooBundle/Resources/public/js/*' filter='uglifyjs2' %}
{% javascripts '@AppBundle/Resources/public/js/*' filter='uglifyjs2' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
.. code-block:: html+php
<?php foreach ($view['assetic']->javascripts(
array('@AcmeFooBundle/Resources/public/js/*'),
array('@AppBundle/Resources/public/js/*'),
array('uglifyj2s')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach ?>
.. note::
The above example assumes that you have a bundle called ``AcmeFooBundle``
The above example assumes that you have a bundle called ``AppBundle``
and your JavaScript files are in the ``Resources/public/js`` directory under
your bundle. This isn't important however - you can include your JavaScript
files no matter where they are.
@@ -197,14 +197,14 @@ apply this filter when debug mode is off (e.g. ``app.php``):
.. code-block:: html+jinja
{% javascripts '@AcmeFooBundle/Resources/public/js/*' filter='?uglifyjs2' %}
{% javascripts '@AppBundle/Resources/public/js/*' filter='?uglifyjs2' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
.. code-block:: html+php
<?php foreach ($view['assetic']->javascripts(
array('@AcmeFooBundle/Resources/public/js/*'),
array('@AppBundle/Resources/public/js/*'),
array('?uglifyjs2')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
@@ -272,14 +272,14 @@ helper:
.. code-block:: html+jinja
{% stylesheets 'bundles/AcmeFoo/css/*' filter='uglifycss' filter='cssrewrite' %}
{% stylesheets 'bundles/App/css/*' filter='uglifycss' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
.. code-block:: html+php
<?php foreach ($view['assetic']->stylesheets(
array('bundles/AcmeFoo/css/*'),
array('bundles/App/css/*'),
array('uglifycss'),
array('cssrewrite')
) as $url): ?>
Oops, something went wrong.

0 comments on commit 528e8e1

Please sign in to comment.