From c6580f896d666e8dbce974033502f08b1d080e66 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 2 Jan 2015 17:27:53 +0100 Subject: [PATCH] Use AppBundle whenever it's possible --- cookbook/assetic/apply_to_option.rst | 24 +++---- cookbook/assetic/asset_management.rst | 66 +++++++++---------- cookbook/assetic/jpeg_optimize.rst | 6 +- cookbook/assetic/uglifyjs.rst | 14 ++-- cookbook/assetic/yuicompressor.rst | 14 ++-- cookbook/bundles/extension.rst | 5 +- cookbook/configuration/apache_router.rst | 12 ++-- cookbook/console/console_command.rst | 10 +-- cookbook/console/logging.rst | 24 +++---- cookbook/console/sending_emails.rst | 2 +- cookbook/controller/error_pages.rst | 10 +-- cookbook/controller/service.rst | 58 ++++++++-------- cookbook/doctrine/custom_dql_functions.rst | 24 +++---- cookbook/doctrine/dbal.rst | 12 ++-- cookbook/doctrine/file_uploads.rst | 20 +++--- .../doctrine/multiple_entity_managers.rst | 8 +-- cookbook/email/testing.rst | 2 +- .../event_dispatcher/before_after_filters.rst | 44 ++++++------- cookbook/form/create_custom_field_type.rst | 44 ++++++------- cookbook/form/dynamic_form_modification.rst | 66 +++++++++---------- cookbook/form/form_customization.rst | 44 ++++++------- cookbook/form/inherit_data_option.rst | 28 ++++---- cookbook/form/use_empty_data.rst | 4 +- cookbook/profiler/matchers.rst | 25 +++---- cookbook/request/mime_type.rst | 24 +++---- cookbook/routing/extra_information.rst | 6 +- cookbook/routing/method_parameters.rst | 18 ++--- cookbook/routing/redirect_in_config.rst | 13 ++-- cookbook/routing/redirect_trailing_slash.rst | 10 +-- cookbook/routing/scheme.rst | 6 +- .../routing/service_container_parameters.rst | 32 ++++----- cookbook/routing/slash_in_parameter.rst | 6 +- cookbook/security/acl.rst | 6 +- .../custom_authentication_provider.rst | 46 ++++++------- cookbook/security/securing_services.rst | 32 ++++----- cookbook/security/target_path.rst | 16 ++--- cookbook/security/voters.rst | 10 +-- cookbook/security/voters_data_permission.rst | 24 +++---- cookbook/service_container/event_listener.rst | 20 +++--- cookbook/service_container/scopes.rst | 44 ++++++------- cookbook/session/locale_sticky_session.rst | 16 ++--- cookbook/templating/PHP.rst | 50 +++++++------- cookbook/templating/namespaced_paths.rst | 8 +-- .../templating/render_without_controller.rst | 14 ++-- cookbook/templating/twig_extension.rst | 22 +++---- cookbook/testing/database.rst | 8 +-- .../testing/simulating_authentication.rst | 10 +-- cookbook/validation/custom_constraint.rst | 43 ++++++------ cookbook/web_services/php_soap_extension.rst | 14 ++-- 49 files changed, 534 insertions(+), 530 deletions(-) diff --git a/cookbook/assetic/apply_to_option.rst b/cookbook/assetic/apply_to_option.rst index 8d5cf98fac8..4c080691f03 100644 --- a/cookbook/assetic/apply_to_option.rst +++ b/cookbook/assetic/apply_to_option.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' %} {% endjavascripts %} .. code-block:: html+php javascripts( - array('@AcmeFooBundle/Resources/public/js/example.coffee'), + array('@AppBundle/Resources/public/js/example.coffee'), array('coffee') ) as $url): ?> @@ -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' %} {% endjavascripts %} @@ -94,8 +94,8 @@ You can also combine multiple CoffeeScript files into a single output file: 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,9 +170,9 @@ 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' %} {% endjavascripts %} @@ -180,9 +180,9 @@ being run through the CoffeeScript filter): 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): ?> diff --git a/cookbook/assetic/asset_management.rst b/cookbook/assetic/asset_management.rst index 6743796edba..785e239b1a0 100644 --- a/cookbook/assetic/asset_management.rst +++ b/cookbook/assetic/asset_management.rst @@ -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/*' %} {% endjavascripts %} .. code-block:: html+php javascripts( - array('@AcmeFooBundle/Resources/public/js/*') + array('@AppBundle/Resources/public/js/*') ) as $url): ?> @@ -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/*' %} {% 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' %} {% endstylesheets %} .. code-block:: html+php stylesheets( - array('bundles/acme_foo/css/*'), + array('bundles/app/css/*'), array('cssrewrite') ) as $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' %} {% endstylesheets %} {% endblock %} @@ -151,11 +151,11 @@ the :ref:`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' %} Example {% endimage %} .. code-block:: html+php image( - array('@AcmeFooBundle/Resources/public/images/example.jpg') + array('@AppBundle/Resources/public/images/example.jpg') ) as $url): ?> Example @@ -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' %} @@ -225,7 +225,7 @@ but still serve them as a single file: javascripts( array( - '@AcmeFooBundle/Resources/public/js/*', + '@AppBundle/Resources/public/js/*', '@AcmeBarBundle/Resources/public/js/form.js', '@AcmeBarBundle/Resources/public/js/calendar.js', ) @@ -254,8 +254,8 @@ 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/*' %} {% endjavascripts %} @@ -263,8 +263,8 @@ combine third party assets, such as jQuery, with your own into a single file: 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): ?> @@ -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 - @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 @@ -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/*' %} {% endjavascripts %} @@ -337,7 +337,7 @@ with the ``@named_asset`` notation: javascripts( array( '@jquery_and_ui', - '@AcmeFooBundle/Resources/public/js/*', + '@AppBundle/Resources/public/js/*', ) ) as $url): ?> @@ -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' %} {% endjavascripts %} .. code-block:: html+php javascripts( - array('@AcmeFooBundle/Resources/public/js/*'), + array('@AppBundle/Resources/public/js/*'), array('uglifyjs2') ) as $url): ?> @@ -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' %} {% endjavascripts %} .. code-block:: html+php 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' %} {% endjavascripts %} .. code-block:: html+php javascripts( - array('@AcmeFooBundle/Resources/public/js/*'), + array('@AppBundle/Resources/public/js/*'), array(), array('output' => 'js/compiled/main.js') ) as $url): ?> diff --git a/cookbook/assetic/jpeg_optimize.rst b/cookbook/assetic/jpeg_optimize.rst index 01f67f6ebcb..7955771ca02 100644 --- a/cookbook/assetic/jpeg_optimize.rst +++ b/cookbook/assetic/jpeg_optimize.rst @@ -57,7 +57,7 @@ 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' %} Example {% endimage %} @@ -65,7 +65,7 @@ It can now be used from a template: .. code-block:: html+php image( - array('@AcmeFooBundle/Resources/public/images/example.jpg'), + array('@AppBundle/Resources/public/images/example.jpg'), array('jpegoptim') ) as $url): ?> Example @@ -204,7 +204,7 @@ The Twig template can now be changed to the following: .. code-block:: html+jinja - Example + Example You can specify the output directory in the config in the following way: diff --git a/cookbook/assetic/uglifyjs.rst b/cookbook/assetic/uglifyjs.rst index 958a1c616a5..a028c50e7b7 100644 --- a/cookbook/assetic/uglifyjs.rst +++ b/cookbook/assetic/uglifyjs.rst @@ -161,14 +161,14 @@ 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' %} {% endjavascripts %} .. code-block:: html+php javascripts( - array('@AcmeFooBundle/Resources/public/js/*'), + array('@AppBundle/Resources/public/js/*'), array('uglifyj2s') ) as $url): ?> @@ -176,7 +176,7 @@ your assets are a part of the view layer, this work is done in your templates: .. 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' %} {% endjavascripts %} .. code-block:: html+php javascripts( - array('@AcmeFooBundle/Resources/public/js/*'), + array('@AppBundle/Resources/public/js/*'), array('?uglifyjs2') ) as $url): ?> @@ -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' %} {% endstylesheets %} .. code-block:: html+php stylesheets( - array('bundles/AcmeFoo/css/*'), + array('bundles/App/css/*'), array('uglifycss'), array('cssrewrite') ) as $url): ?> diff --git a/cookbook/assetic/yuicompressor.rst b/cookbook/assetic/yuicompressor.rst index fedd4dab1da..7e3671fa2fb 100644 --- a/cookbook/assetic/yuicompressor.rst +++ b/cookbook/assetic/yuicompressor.rst @@ -91,14 +91,14 @@ the view layer, this work is done in your templates: .. code-block:: html+jinja - {% javascripts '@AcmeFooBundle/Resources/public/js/*' filter='yui_js' %} + {% javascripts '@AppBundle/Resources/public/js/*' filter='yui_js' %} {% endjavascripts %} .. code-block:: html+php javascripts( - array('@AcmeFooBundle/Resources/public/js/*'), + array('@AppBundle/Resources/public/js/*'), array('yui_js') ) as $url): ?> @@ -106,7 +106,7 @@ the view layer, this work is done in your templates: .. 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. @@ -119,14 +119,14 @@ can be repeated to minify your stylesheets. .. code-block:: html+jinja - {% stylesheets '@AcmeFooBundle/Resources/public/css/*' filter='yui_css' %} + {% stylesheets '@AppBundle/Resources/public/css/*' filter='yui_css' %} {% endstylesheets %} .. code-block:: html+php stylesheets( - array('@AcmeFooBundle/Resources/public/css/*'), + array('@AppBundle/Resources/public/css/*'), array('yui_css') ) as $url): ?> @@ -145,14 +145,14 @@ apply this filter when debug mode is off. .. code-block:: html+jinja - {% javascripts '@AcmeFooBundle/Resources/public/js/*' filter='?yui_js' %} + {% javascripts '@AppBundle/Resources/public/js/*' filter='?yui_js' %} {% endjavascripts %} .. code-block:: html+php javascripts( - array('@AcmeFooBundle/Resources/public/js/*'), + array('@AppBundle/Resources/public/js/*'), array('?yui_js') ) as $url): ?> diff --git a/cookbook/bundles/extension.rst b/cookbook/bundles/extension.rst index d335b8a3f26..bdaf74570a6 100644 --- a/cookbook/bundles/extension.rst +++ b/cookbook/bundles/extension.rst @@ -23,8 +23,9 @@ following conventions: * It has to live in the ``DependencyInjection`` namespace of the bundle; * The name is equal to the bundle name with the ``Bundle`` suffix replaced by - ``Extension`` (e.g. the Extension class of ``AcmeHelloBundle`` would be - called ``AcmeHelloExtension``). + ``Extension`` (e.g. the Extension class of ``AppBundle`` would be called + ``AppExtension`` and the one for ``AcmeHelloBundle`` would be called + ``AcmeHelloExtension``). The Extension class should implement the :class:`Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface`, diff --git a/cookbook/configuration/apache_router.rst b/cookbook/configuration/apache_router.rst index 90f652992f4..7fdcb7cc57c 100644 --- a/cookbook/configuration/apache_router.rst +++ b/cookbook/configuration/apache_router.rst @@ -52,7 +52,7 @@ Symfony to use the ``ApacheUrlMatcher`` instead of the default one: Generating mod_rewrite Rules ---------------------------- -To test that it's working, create a very basic route for the AcmeDemoBundle: +To test that it's working, create a very basic route for the AppBundle: .. configuration-block:: @@ -61,20 +61,20 @@ To test that it's working, create a very basic route for the AcmeDemoBundle: # app/config/routing.yml hello: path: /hello/{name} - defaults: { _controller: AcmeDemoBundle:Demo:hello } + defaults: { _controller: AppBundle:Demo:hello } .. code-block:: xml - AcmeDemoBundle:Demo:hello + AppBundle:Demo:hello .. code-block:: php // app/config/routing.php $collection->add('hello', new Route('/hello/{name}', array( - '_controller' => 'AcmeDemoBundle:Demo:hello', + '_controller' => 'AppBundle:Demo:hello', ))); Now generate the mod_rewrite rules: @@ -93,7 +93,7 @@ Which should roughly output the following: # hello RewriteCond %{REQUEST_URI} ^/hello/([^/]+?)$ - RewriteRule .* app.php [QSA,L,E=_ROUTING__route:hello,E=_ROUTING_name:%1,E=_ROUTING__controller:AcmeDemoBundle\:Demo\:hello] + RewriteRule .* app.php [QSA,L,E=_ROUTING__route:hello,E=_ROUTING_name:%1,E=_ROUTING__controller:AppBundle\:Demo\:hello] You can now rewrite ``web/.htaccess`` to use the new rules, so with this example it should look like this: @@ -109,7 +109,7 @@ it should look like this: # hello RewriteCond %{REQUEST_URI} ^/hello/([^/]+?)$ - RewriteRule .* app.php [QSA,L,E=_ROUTING__route:hello,E=_ROUTING_name:%1,E=_ROUTING__controller:AcmeDemoBundle\:Demo\:hello] + RewriteRule .* app.php [QSA,L,E=_ROUTING__route:hello,E=_ROUTING_name:%1,E=_ROUTING__controller:AppBundle\:Demo\:hello] .. note:: diff --git a/cookbook/console/console_command.rst b/cookbook/console/console_command.rst index 4a2ea5cafb2..2959a2c5044 100644 --- a/cookbook/console/console_command.rst +++ b/cookbook/console/console_command.rst @@ -14,11 +14,11 @@ Automatically Registering Commands To make the console commands available automatically with Symfony, create a ``Command`` directory inside your bundle and create a PHP file suffixed with ``Command.php`` for each command that you want to provide. For example, if you -want to extend the AcmeDemoBundle to greet you from the command line, create +want to extend the AppBundle to greet you from the command line, create ``GreetCommand.php`` and add the following to it:: - // src/Acme/DemoBundle/Command/GreetCommand.php - namespace Acme\DemoBundle\Command; + // src/AppBundle/Command/GreetCommand.php + namespace AppBundle\Command; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputArgument; @@ -147,7 +147,7 @@ instead of use Symfony\Component\Console\Tester\CommandTester; use Symfony\Bundle\FrameworkBundle\Console\Application; - use Acme\DemoBundle\Command\GreetCommand; + use AppBundle\Command\GreetCommand; class ListCommandTest extends \PHPUnit_Framework_TestCase { @@ -186,7 +186,7 @@ you can extend your test from use Symfony\Component\Console\Tester\CommandTester; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; - use Acme\DemoBundle\Command\GreetCommand; + use AppBundle\Command\GreetCommand; class ListCommandTest extends WebTestCase { diff --git a/cookbook/console/logging.rst b/cookbook/console/logging.rst index 031121051f1..df5d6b97f97 100644 --- a/cookbook/console/logging.rst +++ b/cookbook/console/logging.rst @@ -26,8 +26,8 @@ extends :class:`Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand This means that you can simply access the standard logger service through the container and use it to do the logging:: - // src/Acme/DemoBundle/Command/GreetCommand.php - namespace Acme\DemoBundle\Command; + // src/AppBundle/Command/GreetCommand.php + namespace AppBundle\Command; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputArgument; @@ -84,7 +84,7 @@ First configure a listener for console exception events in the service container # app/config/services.yml services: kernel.listener.command_dispatch: - class: Acme\DemoBundle\EventListener\ConsoleExceptionListener + class: AppBundle\EventListener\ConsoleExceptionListener arguments: logger: "@logger" tags: @@ -99,7 +99,7 @@ First configure a listener for console exception events in the service container xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - + @@ -113,7 +113,7 @@ First configure a listener for console exception events in the service container use Symfony\Component\DependencyInjection\Reference; $definitionConsoleExceptionListener = new Definition( - 'Acme\DemoBundle\EventListener\ConsoleExceptionListener', + 'AppBundle\EventListener\ConsoleExceptionListener', array(new Reference('logger')) ); $definitionConsoleExceptionListener->addTag( @@ -127,8 +127,8 @@ First configure a listener for console exception events in the service container Then implement the actual listener:: - // src/Acme/DemoBundle/EventListener/ConsoleExceptionListener.php - namespace Acme\DemoBundle\EventListener; + // src/AppBundle/EventListener/ConsoleExceptionListener.php + namespace AppBundle\EventListener; use Symfony\Component\Console\Event\ConsoleExceptionEvent; use Psr\Log\LoggerInterface; @@ -182,7 +182,7 @@ First configure a listener for console terminate events in the service container # app/config/services.yml services: kernel.listener.command_dispatch: - class: Acme\DemoBundle\EventListener\ErrorLoggerListener + class: AppBundle\EventListener\ErrorLoggerListener arguments: logger: "@logger" tags: @@ -197,7 +197,7 @@ First configure a listener for console terminate events in the service container xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - + @@ -211,7 +211,7 @@ First configure a listener for console terminate events in the service container use Symfony\Component\DependencyInjection\Reference; $definitionErrorLoggerListener = new Definition( - 'Acme\DemoBundle\EventListener\ErrorLoggerListener', + 'AppBundle\EventListener\ErrorLoggerListener', array(new Reference('logger')) ); $definitionErrorLoggerListener->addTag( @@ -225,8 +225,8 @@ First configure a listener for console terminate events in the service container Then implement the actual listener:: - // src/Acme/DemoBundle/EventListener/ErrorLoggerListener.php - namespace Acme\DemoBundle\EventListener; + // src/AppBundle/EventListener/ErrorLoggerListener.php + namespace AppBundle\EventListener; use Symfony\Component\Console\Event\ConsoleTerminateEvent; use Psr\Log\LoggerInterface; diff --git a/cookbook/console/sending_emails.rst b/cookbook/console/sending_emails.rst index 2ecd95e4104..c6e870189e5 100644 --- a/cookbook/console/sending_emails.rst +++ b/cookbook/console/sending_emails.rst @@ -69,7 +69,7 @@ Configuring the Request Context per Command To change it only in one command you can simply fetch the Request Context from the ``router`` service and override its settings:: - // src/Acme/DemoBundle/Command/DemoCommand.php + // src/AppBundle/Command/DemoCommand.php // ... class DemoCommand extends ContainerAwareCommand diff --git a/cookbook/controller/error_pages.rst b/cookbook/controller/error_pages.rst index fa8efef21fc..3217c602017 100644 --- a/cookbook/controller/error_pages.rst +++ b/cookbook/controller/error_pages.rst @@ -178,7 +178,7 @@ to point to it. # app/config/config.yml twig: - exception_controller: AcmeFooBundle:Exception:showException + exception_controller: AppBundle:Exception:showException .. code-block:: xml @@ -191,7 +191,7 @@ to point to it. http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd"> - AcmeFooBundle:Exception:showException + AppBundle:Exception:showException @@ -199,7 +199,7 @@ to point to it. // app/config/config.php $container->loadFromExtension('twig', array( - 'exception_controller' => 'AcmeFooBundle:Exception:showException', + 'exception_controller' => 'AppBundle:Exception:showException', // ... )); @@ -265,7 +265,7 @@ another page or rendering specialized error pages. If your listener calls ``setResponse()`` on the :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent`, - event propagation will be stopped and the response will be sent to + event propagation will be stopped and the response will be sent to the client. This approach allows you to create centralized and layered error @@ -277,7 +277,7 @@ several) listeners deal with them. To see an example, have a look at the `ExceptionListener`_ in the Security Component. - + It handles various security-related exceptions that are thrown in your application (like :class:`Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException`) and takes measures like redirecting the user to the login page, diff --git a/cookbook/controller/service.rst b/cookbook/controller/service.rst index bf2cadb2887..1ce43de4911 100644 --- a/cookbook/controller/service.rst +++ b/cookbook/controller/service.rst @@ -34,8 +34,8 @@ Defining the Controller as a Service A controller can be defined as a service in the same way as any other class. For example, if you have the following simple controller:: - // src/Acme/HelloBundle/Controller/HelloController.php - namespace Acme\HelloBundle\Controller; + // src/AppBundle/Controller/HelloController.php + namespace AppBundle\Controller; use Symfony\Component\HttpFoundation\Response; @@ -53,25 +53,25 @@ Then you can define it as a service as follows: .. code-block:: yaml - # src/Acme/HelloBundle/Resources/config/services.yml + # app/config/services.yml services: - acme.hello.controller: - class: Acme\HelloBundle\Controller\HelloController + app.hello_controller: + class: AppBundle\Controller\HelloController .. code-block:: xml - + - + .. code-block:: php - // src/Acme/HelloBundle/Resources/config/services.php + // app/config/services.php use Symfony\Component\DependencyInjection\Definition; - $container->setDefinition('acme.hello.controller', new Definition( - 'Acme\HelloBundle\Controller\HelloController' + $container->setDefinition('app.hello_controller', new Definition( + 'AppBundle\Controller\HelloController' )); Referring to the Service @@ -79,9 +79,9 @@ Referring to the Service To refer to a controller that's defined as a service, use the single colon (:) notation. For example, to forward to the ``indexAction()`` method of the service -defined above with the id ``acme.hello.controller``:: +defined above with the id ``app.hello_controller``:: - $this->forward('acme.hello.controller:indexAction', array('name' => $name)); + $this->forward('app.hello_controller:indexAction', array('name' => $name)); .. note:: @@ -98,20 +98,20 @@ the route ``_controller`` value: # app/config/routing.yml hello: path: /hello - defaults: { _controller: acme.hello.controller:indexAction } + defaults: { _controller: app.hello_controller:indexAction } .. code-block:: xml - acme.hello.controller:indexAction + app.hello_controller:indexAction .. code-block:: php // app/config/routing.php $collection->add('hello', new Route('/hello', array( - '_controller' => 'acme.hello.controller:indexAction', + '_controller' => 'app.hello_controller:indexAction', ))); .. tip:: @@ -133,8 +133,8 @@ For example, if you want to render a template instead of creating the ``Response object directly, then your code would look like this if you were extending Symfony's base controller:: - // src/Acme/HelloBundle/Controller/HelloController.php - namespace Acme\HelloBundle\Controller; + // src/AppBundle/Controller/HelloController.php + namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; @@ -143,7 +143,7 @@ Symfony's base controller:: public function indexAction($name) { return $this->render( - 'AcmeHelloBundle:Hello:index.html.twig', + 'AppBundle:Hello:index.html.twig', array('name' => $name) ); } @@ -161,8 +161,8 @@ If you look at the source code for the ``render`` function in Symfony's In a controller that's defined as a service, you can instead inject the ``templating`` service and use it directly:: - // src/Acme/HelloBundle/Controller/HelloController.php - namespace Acme\HelloBundle\Controller; + // src/AppBundle/Controller/HelloController.php + namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Component\HttpFoundation\Response; @@ -179,7 +179,7 @@ service and use it directly:: public function indexAction($name) { return $this->templating->renderResponse( - 'AcmeHelloBundle:Hello:index.html.twig', + 'AppBundle:Hello:index.html.twig', array('name' => $name) ); } @@ -192,29 +192,29 @@ argument: .. code-block:: yaml - # src/Acme/HelloBundle/Resources/config/services.yml + # app/config/services.yml services: - acme.hello.controller: - class: Acme\HelloBundle\Controller\HelloController + app.hello_controller: + class: AppBundle\Controller\HelloController arguments: ["@templating"] .. code-block:: xml - + - + .. code-block:: php - // src/Acme/HelloBundle/Resources/config/services.php + // app/config/services.php use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; - $container->setDefinition('acme.hello.controller', new Definition( - 'Acme\HelloBundle\Controller\HelloController', + $container->setDefinition('app.hello_controller', new Definition( + 'AppBundle\Controller\HelloController', array(new Reference('templating')) )); diff --git a/cookbook/doctrine/custom_dql_functions.rst b/cookbook/doctrine/custom_dql_functions.rst index dcdfc6bc492..747a353e7a5 100644 --- a/cookbook/doctrine/custom_dql_functions.rst +++ b/cookbook/doctrine/custom_dql_functions.rst @@ -19,12 +19,12 @@ In Symfony, you can register your custom DQL functions as follows: # ... dql: string_functions: - test_string: Acme\HelloBundle\DQL\StringFunction - second_string: Acme\HelloBundle\DQL\SecondStringFunction + test_string: AppBundle\DQL\StringFunction + second_string: AppBundle\DQL\SecondStringFunction numeric_functions: - test_numeric: Acme\HelloBundle\DQL\NumericFunction + test_numeric: AppBundle\DQL\NumericFunction datetime_functions: - test_datetime: Acme\HelloBundle\DQL\DatetimeFunction + test_datetime: AppBundle\DQL\DatetimeFunction .. code-block:: xml @@ -39,10 +39,10 @@ In Symfony, you can register your custom DQL functions as follows: - Acme\HelloBundle\DQL\StringFunction - Acme\HelloBundle\DQL\SecondStringFunction - Acme\HelloBundle\DQL\NumericFunction - Acme\HelloBundle\DQL\DatetimeFunction + AppBundle\DQL\StringFunction + AppBundle\DQL\SecondStringFunction + AppBundle\DQL\NumericFunction + AppBundle\DQL\DatetimeFunction @@ -56,14 +56,14 @@ In Symfony, you can register your custom DQL functions as follows: // ... 'dql' => array( 'string_functions' => array( - 'test_string' => 'Acme\HelloBundle\DQL\StringFunction', - 'second_string' => 'Acme\HelloBundle\DQL\SecondStringFunction', + 'test_string' => 'AppBundle\DQL\StringFunction', + 'second_string' => 'AppBundle\DQL\SecondStringFunction', ), 'numeric_functions' => array( - 'test_numeric' => 'Acme\HelloBundle\DQL\NumericFunction', + 'test_numeric' => 'AppBundle\DQL\NumericFunction', ), 'datetime_functions' => array( - 'test_datetime' => 'Acme\HelloBundle\DQL\DatetimeFunction', + 'test_datetime' => 'AppBundle\DQL\DatetimeFunction', ), ), ), diff --git a/cookbook/doctrine/dbal.rst b/cookbook/doctrine/dbal.rst index 73d9e07e109..39cb0eabeaf 100644 --- a/cookbook/doctrine/dbal.rst +++ b/cookbook/doctrine/dbal.rst @@ -93,8 +93,8 @@ mapping types, read Doctrine's `Custom Mapping Types`_ section of their document doctrine: dbal: types: - custom_first: Acme\HelloBundle\Type\CustomFirst - custom_second: Acme\HelloBundle\Type\CustomSecond + custom_first: AppBundle\Type\CustomFirst + custom_second: AppBundle\Type\CustomSecond .. code-block:: xml @@ -107,8 +107,8 @@ mapping types, read Doctrine's `Custom Mapping Types`_ section of their document - - + + @@ -119,8 +119,8 @@ mapping types, read Doctrine's `Custom Mapping Types`_ section of their document $container->loadFromExtension('doctrine', array( 'dbal' => array( 'types' => array( - 'custom_first' => 'Acme\HelloBundle\Type\CustomFirst', - 'custom_second' => 'Acme\HelloBundle\Type\CustomSecond', + 'custom_first' => 'AppBundle\Type\CustomFirst', + 'custom_second' => 'AppBundle\Type\CustomSecond', ), ), )); diff --git a/cookbook/doctrine/file_uploads.rst b/cookbook/doctrine/file_uploads.rst index fa400525187..b68806f59d4 100644 --- a/cookbook/doctrine/file_uploads.rst +++ b/cookbook/doctrine/file_uploads.rst @@ -23,8 +23,8 @@ Basic Setup First, create a simple Doctrine entity class to work with:: - // src/Acme/DemoBundle/Entity/Document.php - namespace Acme\DemoBundle\Entity; + // src/AppBundle/Entity/Document.php + namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; @@ -154,8 +154,8 @@ rules:: .. code-block:: yaml - # src/Acme/DemoBundle/Resources/config/validation.yml - Acme\DemoBundle\Entity\Document: + # src/AppBundle/Resources/config/validation.yml + AppBundle\Entity\Document: properties: file: - File: @@ -163,8 +163,8 @@ rules:: .. code-block:: php-annotations - // src/Acme/DemoBundle/Entity/Document.php - namespace Acme\DemoBundle\Entity; + // src/AppBundle/Entity/Document.php + namespace AppBundle\Entity; // ... use Symfony\Component\Validator\Constraints as Assert; @@ -181,8 +181,8 @@ rules:: .. code-block:: xml - - + + @@ -192,7 +192,7 @@ rules:: .. code-block:: php - // src/Acme/DemoBundle/Entity/Document.php + // src/AppBundle/Entity/Document.php namespace Acme\DemoBundle\Entity; // ... @@ -220,7 +220,7 @@ rules:: The following controller shows you how to handle the entire process:: // ... - use Acme\DemoBundle\Entity\Document; + use AppBundle\Entity\Document; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Component\HttpFoundation\Request; // ... diff --git a/cookbook/doctrine/multiple_entity_managers.rst b/cookbook/doctrine/multiple_entity_managers.rst index 689d9d1bba2..ce2a3f685c6 100644 --- a/cookbook/doctrine/multiple_entity_managers.rst +++ b/cookbook/doctrine/multiple_entity_managers.rst @@ -49,7 +49,7 @@ The following configuration code shows how you can configure two entity managers default: connection: default mappings: - AcmeDemoBundle: ~ + AppBundle: ~ AcmeStoreBundle: ~ customer: connection: customer @@ -90,7 +90,7 @@ The following configuration code shows how you can configure two entity managers - + @@ -134,7 +134,7 @@ The following configuration code shows how you can configure two entity managers 'default' => array( 'connection' => 'default', 'mappings' => array( - 'AcmeDemoBundle' => null, + 'AppBundle' => null, 'AcmeStoreBundle' => null, ), ), @@ -150,7 +150,7 @@ The following configuration code shows how you can configure two entity managers In this case, you've defined two entity managers and called them ``default`` and ``customer``. The ``default`` entity manager manages entities in the -``AcmeDemoBundle`` and ``AcmeStoreBundle``, while the ``customer`` entity +``AppBundle`` and ``AcmeStoreBundle``, while the ``customer`` entity manager manages entities in the ``AcmeCustomerBundle``. You've also defined two connections, one for each entity manager. diff --git a/cookbook/email/testing.rst b/cookbook/email/testing.rst index db6e717ec36..d5fce3b4186 100644 --- a/cookbook/email/testing.rst +++ b/cookbook/email/testing.rst @@ -33,7 +33,7 @@ Start with an easy controller action that sends an e-mail:: In your functional test, use the ``swiftmailer`` collector on the profiler to get information about the messages send on the previous request:: - // src/Acme/DemoBundle/Tests/Controller/MailControllerTest.php + // src/AppBundle/Tests/Controller/MailControllerTest.php use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class MailControllerTest extends WebTestCase diff --git a/cookbook/event_dispatcher/before_after_filters.rst b/cookbook/event_dispatcher/before_after_filters.rst index 28ca972faec..262365037b5 100644 --- a/cookbook/event_dispatcher/before_after_filters.rst +++ b/cookbook/event_dispatcher/before_after_filters.rst @@ -74,7 +74,7 @@ controller that matches the request needs token validation. A clean and easy way is to create an empty interface and make the controllers implement it:: - namespace Acme\DemoBundle\Controller; + namespace AppBundle\Controller; interface TokenAuthenticatedController { @@ -83,9 +83,9 @@ implement it:: A controller that implements this interface simply looks like this:: - namespace Acme\DemoBundle\Controller; + namespace AppBundle\Controller; - use Acme\DemoBundle\Controller\TokenAuthenticatedController; + use AppBundle\Controller\TokenAuthenticatedController; use Symfony\Bundle\FrameworkBundle\Controller\Controller; class FooController extends Controller implements TokenAuthenticatedController @@ -104,10 +104,10 @@ Next, you'll need to create an event listener, which will hold the logic that you want executed before your controllers. If you're not familiar with event listeners, you can learn more about them at :doc:`/cookbook/service_container/event_listener`:: - // src/Acme/DemoBundle/EventListener/TokenListener.php - namespace Acme\DemoBundle\EventListener; + // src/AppBundle/EventListener/TokenListener.php + namespace AppBundle\EventListener; - use Acme\DemoBundle\Controller\TokenAuthenticatedController; + use AppBundle\Controller\TokenAuthenticatedController; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Event\FilterControllerEvent; @@ -153,33 +153,33 @@ your listener to be called just before any controller is executed. .. code-block:: yaml - # app/config/config.yml (or inside your services.yml) + # app/config/services.yml services: - demo.tokens.action_listener: - class: Acme\DemoBundle\EventListener\TokenListener + app.tokens.action_listener: + class: AappBundle\EventListener\TokenListener arguments: ["%tokens%"] tags: - { name: kernel.event_listener, event: kernel.controller, method: onKernelController } .. code-block:: xml - - + + %tokens% .. code-block:: php - // app/config/config.php (or inside your services.php) + // app/config/services.php use Symfony\Component\DependencyInjection\Definition; - $listener = new Definition('Acme\DemoBundle\EventListener\TokenListener', array('%tokens%')); + $listener = new Definition('AppBundle\EventListener\TokenListener', array('%tokens%')); $listener->addTag('kernel.event_listener', array( 'event' => 'kernel.controller', 'method' => 'onKernelController' )); - $container->setDefinition('demo.tokens.action_listener', $listener); + $container->setDefinition('app.tokens.action_listener', $listener); With this configuration, your ``TokenListener`` ``onKernelController`` method will be executed on each request. If the controller that is about to be executed @@ -248,10 +248,10 @@ event: .. code-block:: yaml - # app/config/config.yml (or inside your services.yml) + # app/config/services.yml services: - demo.tokens.action_listener: - class: Acme\DemoBundle\EventListener\TokenListener + app.tokens.action_listener: + class: AppBundle\EventListener\TokenListener arguments: ["%tokens%"] tags: - { name: kernel.event_listener, event: kernel.controller, method: onKernelController } @@ -259,8 +259,8 @@ event: .. code-block:: xml - - + + %tokens% @@ -268,10 +268,10 @@ event: .. code-block:: php - // app/config/config.php (or inside your services.php) + // app/config/services.php use Symfony\Component\DependencyInjection\Definition; - $listener = new Definition('Acme\DemoBundle\EventListener\TokenListener', array('%tokens%')); + $listener = new Definition('AppBundle\EventListener\TokenListener', array('%tokens%')); $listener->addTag('kernel.event_listener', array( 'event' => 'kernel.controller', 'method' => 'onKernelController' @@ -280,7 +280,7 @@ event: 'event' => 'kernel.response', 'method' => 'onKernelResponse' )); - $container->setDefinition('demo.tokens.action_listener', $listener); + $container->setDefinition('app.tokens.action_listener', $listener); That's it! The ``TokenListener`` is now notified before every controller is executed (``onKernelController``) and after every controller returns a response diff --git a/cookbook/form/create_custom_field_type.rst b/cookbook/form/create_custom_field_type.rst index 891a274f7a8..17b28778bac 100644 --- a/cookbook/form/create_custom_field_type.rst +++ b/cookbook/form/create_custom_field_type.rst @@ -20,8 +20,8 @@ will be called ``GenderType`` and the file will be stored in the default locatio for form fields, which is ``\Form\Type``. Make sure the field extends :class:`Symfony\\Component\\Form\\AbstractType`:: - // src/Acme/DemoBundle/Form/Type/GenderType.php - namespace Acme\DemoBundle\Form\Type; + // src/AppBundle/Form/Type/GenderType.php + namespace AppBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\OptionsResolverInterface; @@ -111,7 +111,7 @@ link for details), create a ``gender_widget`` block to handle this: .. code-block:: html+jinja - {# src/Acme/DemoBundle/Resources/views/Form/fields.html.twig #} + {# src/AppBundle/Resources/views/Form/fields.html.twig #} {% block gender_widget %} {% spaceless %} {% if expanded %} @@ -132,7 +132,7 @@ link for details), create a ``gender_widget`` block to handle this: .. code-block:: html+php - +
    block($form, 'widget_container_attributes') ?>> @@ -164,14 +164,14 @@ link for details), create a ``gender_widget`` block to handle this: twig: form: resources: - - 'AcmeDemoBundle:Form:fields.html.twig' + - 'AppBundle:Form:fields.html.twig' .. code-block:: xml - AcmeDemoBundle:Form:fields.html.twig + AppBundle:Form:fields.html.twig @@ -181,7 +181,7 @@ link for details), create a ``gender_widget`` block to handle this: $container->loadFromExtension('twig', array( 'form' => array( 'resources' => array( - 'AcmeDemoBundle:Form:fields.html.twig', + 'AppBundle:Form:fields.html.twig', ), ), )); @@ -197,7 +197,7 @@ link for details), create a ``gender_widget`` block to handle this: templating: form: resources: - - 'AcmeDemoBundle:Form' + - 'AppBundle:Form' .. code-block:: xml @@ -212,7 +212,7 @@ link for details), create a ``gender_widget`` block to handle this: - AcmeDemoBundle:Form + AppBundle:Form @@ -225,7 +225,7 @@ link for details), create a ``gender_widget`` block to handle this: 'templating' => array( 'form' => array( 'resources' => array( - 'AcmeDemoBundle:Form', + 'AppBundle:Form', ), ), ), @@ -237,8 +237,8 @@ Using the Field Type You can now use your custom field type immediately, simply by creating a new instance of the type in one of your forms:: - // src/Acme/DemoBundle/Form/Type/AuthorType.php - namespace Acme\DemoBundle\Form\Type; + // src/AppBundle/Form/Type/AuthorType.php + namespace AppBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; @@ -301,10 +301,10 @@ the ``genders`` parameter value as the first argument to its to-be-created .. code-block:: yaml - # src/Acme/DemoBundle/Resources/config/services.yml + # src/AppBundle/Resources/config/services.yml services: acme_demo.form.type.gender: - class: Acme\DemoBundle\Form\Type\GenderType + class: AppBundle\Form\Type\GenderType arguments: - "%genders%" tags: @@ -312,20 +312,20 @@ the ``genders`` parameter value as the first argument to its to-be-created .. code-block:: xml - - + + %genders% .. code-block:: php - // src/Acme/DemoBundle/Resources/config/services.php + // src/AppBundle/Resources/config/services.php use Symfony\Component\DependencyInjection\Definition; $container ->setDefinition('acme_demo.form.type.gender', new Definition( - 'Acme\DemoBundle\Form\Type\GenderType', + 'AppBundle\Form\Type\GenderType', array('%genders%') )) ->addTag('form.type', array( @@ -343,8 +343,8 @@ returned by the ``getName`` method defined earlier. You'll see the importance of this in a moment when you use the custom field type. But first, add a ``__construct`` method to ``GenderType``, which receives the gender configuration:: - // src/Acme/DemoBundle/Form/Type/GenderType.php - namespace Acme\DemoBundle\Form\Type; + // src/AppBundle/Form/Type/GenderType.php + namespace AppBundle\Form\Type; use Symfony\Component\OptionsResolver\OptionsResolverInterface; @@ -374,8 +374,8 @@ Great! The ``GenderType`` is now fueled by the configuration parameters and registered as a service. Additionally, because you used the ``form.type`` alias in its configuration, using the field is now much easier:: - // src/Acme/DemoBundle/Form/Type/AuthorType.php - namespace Acme\DemoBundle\Form\Type; + // src/AppBundle/Form/Type/AuthorType.php + namespace AppBundle\Form\Type; use Symfony\Component\Form\FormBuilderInterface; diff --git a/cookbook/form/dynamic_form_modification.rst b/cookbook/form/dynamic_form_modification.rst index 36b4b9e9800..462d6a1f7d6 100644 --- a/cookbook/form/dynamic_form_modification.rst +++ b/cookbook/form/dynamic_form_modification.rst @@ -36,8 +36,8 @@ Customizing your Form Based on the Underlying Data Before jumping right into dynamic form generation, hold on and recall what a bare form class looks like:: - // src/Acme/DemoBundle/Form/Type/ProductType.php - namespace Acme\DemoBundle\Form\Type; + // src/AppBundle/Form/Type/ProductType.php + namespace AppBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; @@ -54,7 +54,7 @@ a bare form class looks like:: public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( - 'data_class' => 'Acme\DemoBundle\Entity\Product' + 'data_class' => 'AppBundle\Entity\Product' )); } @@ -90,8 +90,8 @@ Adding an Event Listener to a Form Class So, instead of directly adding that ``name`` widget, the responsibility of creating that particular field is delegated to an event listener:: - // src/Acme/DemoBundle/Form/Type/ProductType.php - namespace Acme\DemoBundle\Form\Type; + // src/AppBundle/Form/Type/ProductType.php + namespace AppBundle\Form\Type; // ... use Symfony\Component\Form\FormEvent; @@ -156,11 +156,11 @@ For better reusability or if there is some heavy logic in your event listener, you can also move the logic for creating the ``name`` field to an :ref:`event subscriber `:: - // src/Acme/DemoBundle/Form/Type/ProductType.php - namespace Acme\DemoBundle\Form\Type; + // src/AppBundle/Form/Type/ProductType.php + namespace AppBundle\Form\Type; // ... - use Acme\DemoBundle\Form\EventListener\AddNameFieldSubscriber; + use AppBundle\Form\EventListener\AddNameFieldSubscriber; class ProductType extends AbstractType { @@ -177,8 +177,8 @@ you can also move the logic for creating the ``name`` field to an Now the logic for creating the ``name`` field resides in it own subscriber class:: - // src/Acme/DemoBundle/Form/EventListener/AddNameFieldSubscriber.php - namespace Acme\DemoBundle\Form\EventListener; + // src/AppBundle/Form/EventListener/AddNameFieldSubscriber.php + namespace AppBundle\Form\EventListener; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; @@ -221,8 +221,8 @@ Creating the Form Type Using an event listener, your form might look like this:: - // src/Acme/DemoBundle/Form/Type/FriendMessageFormType.php - namespace Acme\DemoBundle\Form\Type; + // src/AppBundle/Form/Type/FriendMessageFormType.php + namespace AppBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; @@ -283,7 +283,7 @@ Customizing the Form Type Now that you have all the basics in place you can take advantage of the ``SecurityContext`` and fill in the listener logic:: - // src/Acme/DemoBundle/FormType/FriendMessageFormType.php + // src/AppBundle/FormType/FriendMessageFormType.php use Symfony\Component\Security\Core\SecurityContext; use Doctrine\ORM\EntityRepository; @@ -319,7 +319,7 @@ and fill in the listener logic:: $form = $event->getForm(); $formOptions = array( - 'class' => 'Acme\DemoBundle\Entity\User', + 'class' => 'AppBundle\Entity\User', 'property' => 'fullName', 'query_builder' => function (EntityRepository $er) use ($user) { // build a custom query @@ -390,7 +390,7 @@ it with :ref:`dic-tags-form-type`. # app/config/config.yml services: acme.form.friend_message: - class: Acme\DemoBundle\Form\Type\FriendMessageFormType + class: AppBundle\Form\Type\FriendMessageFormType arguments: ["@security.context"] tags: - { name: form.type, alias: acme_friend_message } @@ -399,7 +399,7 @@ it with :ref:`dic-tags-form-type`. - + @@ -408,7 +408,7 @@ it with :ref:`dic-tags-form-type`. .. code-block:: php // app/config/config.php - $definition = new Definition('Acme\DemoBundle\Form\Type\FriendMessageFormType'); + $definition = new Definition('AppBundle\Form\Type\FriendMessageFormType'); $definition->addTag('form.type', array('alias' => 'acme_friend_message')); $container->setDefinition( 'acme.form.friend_message', @@ -459,8 +459,8 @@ will need the correct options in order for validation to pass. The meetup is passed as an entity field to the form. So we can access each sport like this:: - // src/Acme/DemoBundle/Form/Type/SportMeetupType.php - namespace Acme\DemoBundle\Form\Type; + // src/AppBundle/Form/Type/SportMeetupType.php + namespace AppBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; @@ -474,7 +474,7 @@ sport like this:: { $builder ->add('sport', 'entity', array( - 'class' => 'AcmeDemoBundle:Sport', + 'class' => 'AppBundle:Sport', 'empty_value' => '', )) ; @@ -491,7 +491,7 @@ sport like this:: $positions = null === $sport ? array() : $sport->getAvailablePositions(); $form->add('position', 'entity', array( - 'class' => 'AcmeDemoBundle:Position', + 'class' => 'AppBundle:Position', 'empty_value' => '', 'choices' => $positions, )); @@ -532,12 +532,12 @@ new field automatically and map it to the submitted client data. The type would now look like:: - // src/Acme/DemoBundle/Form/Type/SportMeetupType.php - namespace Acme\DemoBundle\Form\Type; + // src/AppBundle/Form/Type/SportMeetupType.php + namespace AppBundle\Form\Type; // ... use Symfony\Component\Form\FormInterface; - use Acme\DemoBundle\Entity\Sport; + use AppBundle\Entity\Sport; class SportMeetupType extends AbstractType { @@ -545,7 +545,7 @@ The type would now look like:: { $builder ->add('sport', 'entity', array( - 'class' => 'AcmeDemoBundle:Sport', + 'class' => 'AppBundle:Sport', 'empty_value' => '', )); ; @@ -554,7 +554,7 @@ The type would now look like:: $positions = null === $sport ? array() : $sport->getAvailablePositions(); $form->add('position', 'entity', array( - 'class' => 'AcmeDemoBundle:Position', + 'class' => 'AppBundle:Position', 'empty_value' => '', 'choices' => $positions, )); @@ -596,13 +596,13 @@ One piece that is still missing is the client-side updating of your form after the sport is selected. This should be handled by making an AJAX call back to your application. Assume that you have a sport meetup creation controller:: - // src/Acme/DemoBundle/Controller/MeetupController.php - namespace Acme\DemoBundle\Controller; + // src/AppBundle/Controller/MeetupController.php + namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; - use Acme\DemoBundle\Entity\SportMeetup; - use Acme\DemoBundle\Form\Type\SportMeetupType; + use AppBundle\Entity\SportMeetup; + use AppBundle\Form\Type\SportMeetupType; // ... class MeetupController extends Controller @@ -617,7 +617,7 @@ your application. Assume that you have a sport meetup creation controller:: } return $this->render( - 'AcmeDemoBundle:Meetup:create.html.twig', + 'AppBundle:Meetup:create.html.twig', array('form' => $form->createView()) ); } @@ -632,7 +632,7 @@ field according to the current selection in the ``sport`` field: .. code-block:: html+jinja - {# src/Acme/DemoBundle/Resources/views/Meetup/create.html.twig #} + {# src/AppBundle/Resources/views/Meetup/create.html.twig #} {{ form_start(form) }} {{ form_row(form.sport) }} {#