From da6710574bc893502d573960f55e5ec53d985878 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 13 Nov 2017 20:36:27 +0100 Subject: [PATCH 1/5] Updated reference articles to Symfony 4 --- reference/configuration/assetic.rst | 119 +----------- reference/configuration/debug.rst | 6 +- reference/configuration/doctrine.rst | 52 +++--- reference/configuration/framework.rst | 80 ++++---- reference/configuration/kernel.rst | 31 ++-- reference/configuration/monolog.rst | 4 +- reference/configuration/security.rst | 28 +-- reference/configuration/swiftmailer.rst | 9 +- reference/configuration/twig.rst | 18 +- reference/configuration/web_profiler.rst | 4 +- reference/constraints/All.rst | 2 +- reference/constraints/Bic.rst | 2 +- reference/constraints/Blank.rst | 2 +- reference/constraints/Callback.rst | 4 +- reference/constraints/CardScheme.rst | 2 +- reference/constraints/Choice.rst | 6 +- reference/constraints/Collection.rst | 4 +- reference/constraints/Count.rst | 2 +- reference/constraints/Country.rst | 2 +- reference/constraints/Currency.rst | 2 +- reference/constraints/Date.rst | 2 +- reference/constraints/DateTime.rst | 2 +- reference/constraints/Email.rst | 2 +- reference/constraints/EqualTo.rst | 2 +- reference/constraints/Expression.rst | 4 +- reference/constraints/File.rst | 2 +- reference/constraints/GreaterThan.rst | 8 +- reference/constraints/GreaterThanOrEqual.rst | 8 +- reference/constraints/Iban.rst | 2 +- reference/constraints/IdenticalTo.rst | 2 +- reference/constraints/Image.rst | 4 +- reference/constraints/Ip.rst | 2 +- reference/constraints/IsFalse.rst | 2 +- reference/constraints/IsNull.rst | 2 +- reference/constraints/IsTrue.rst | 2 +- reference/constraints/Isbn.rst | 2 +- reference/constraints/Issn.rst | 2 +- reference/constraints/Language.rst | 2 +- reference/constraints/Length.rst | 2 +- reference/constraints/LessThan.rst | 8 +- reference/constraints/LessThanOrEqual.rst | 8 +- reference/constraints/Locale.rst | 2 +- reference/constraints/Luhn.rst | 2 +- reference/constraints/NotBlank.rst | 2 +- reference/constraints/NotEqualTo.rst | 2 +- reference/constraints/NotIdenticalTo.rst | 2 +- reference/constraints/NotNull.rst | 2 +- reference/constraints/Range.rst | 8 +- reference/constraints/Regex.rst | 6 +- reference/constraints/Time.rst | 2 +- reference/constraints/Type.rst | 2 +- reference/constraints/UniqueEntity.rst | 11 +- reference/constraints/Url.rst | 10 +- reference/constraints/UserPassword.rst | 2 +- reference/constraints/Uuid.rst | 2 +- reference/constraints/Valid.rst | 4 +- reference/dic_tags.rst | 185 +------------------ reference/forms/types/entity.rst | 2 +- reference/map.rst.inc | 2 +- 59 files changed, 202 insertions(+), 495 deletions(-) diff --git a/reference/configuration/assetic.rst b/reference/configuration/assetic.rst index 4331d8117a7..a30ba7ef450 100644 --- a/reference/configuration/assetic.rst +++ b/reference/configuration/assetic.rst @@ -4,119 +4,8 @@ AsseticBundle Configuration ("assetic") ======================================= -.. include:: /assetic/_standard_edition_warning.rst.inc +.. caution:: -Full Default Configuration --------------------------- - -.. configuration-block:: - - .. code-block:: yaml - - # app/config/config.yml - assetic: - debug: '%kernel.debug%' - use_controller: - enabled: '%kernel.debug%' - profiler: false - read_from: '%assetic.read_from%' - write_to: '%kernel.project_dir%/web' - java: /usr/bin/java - node: /usr/bin/node - ruby: /usr/bin/ruby - sass: /usr/bin/sass - # An key-value pair of any number of named elements - variables: - some_name: [] - bundles: - - # Defaults (all currently registered bundles): - - FrameworkBundle - - SecurityBundle - - TwigBundle - - MonologBundle - - SwiftmailerBundle - - DoctrineBundle - - AsseticBundle - - ... - assets: - # An array of named assets (e.g. some_asset, some_other_asset) - some_asset: - inputs: [] - filters: [] - options: - # A key-value array of options and values - some_option_name: [] - filters: - - # An array of named filters (e.g. some_filter, some_other_filter) - some_filter: [] - workers: - # see https://github.com/symfony/AsseticBundle/pull/119 - # Cache can also be busted via the framework.assets.version - # setting - see the "framework" configuration section - cache_busting: - enabled: false - twig: - functions: - # An array of named functions (e.g. some_function, some_other_function) - some_function: [] - - .. code-block:: xml - - - - - - - - - FrameworkBundle - SecurityBundle - TwigBundle - MonologBundle - SwiftmailerBundle - DoctrineBundle - AsseticBundle - ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Assetic is no longer recommended to manage web assets in Symfony + applications. Instead, use :doc:`Webpack Encore `, which bridges + Symfony applications with modern JavaScript tools used to manage web assets. diff --git a/reference/configuration/debug.rst b/reference/configuration/debug.rst index b9185488a68..3eb822cd62a 100644 --- a/reference/configuration/debug.rst +++ b/reference/configuration/debug.rst @@ -64,13 +64,13 @@ destination for dumps. Typically, you would set this to ``php://stderr``: .. code-block:: yaml - # app/config/config.yml + # config/packages/debug.yaml debug: dump_destination: php://stderr .. code-block:: xml - + loadFromExtension('debug', array( 'dump_destination' => 'php://stderr', )); diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index d7e32a282a4..d5d8efd97e8 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -12,7 +12,7 @@ Full Default Configuration .. code-block:: yaml - # app/config/config.yml + # config/packages/doctrine.yaml doctrine: dbal: default_connection: default @@ -20,9 +20,9 @@ Full Default Configuration # A collection of custom types # Example some_custom_type: - class: Acme\HelloBundle\MyCustomType + class: App\Bridge\Doctrine\DBAL\MyCustomType commented: true - + connections: # A collection of different named connections (e.g. default, conn2, etc) @@ -75,11 +75,11 @@ Full Default Configuration mapping_types: # an array of mapping types name: [] - + # If defined, only the tables whose names match this regular expression are managed # by the schema tool (in this example, any table name not starting with `wp_`) #schema_filter: '/^(?!wp_)/' - + slaves: # a collection of named slave connections (e.g. slave1, slave2) @@ -163,17 +163,17 @@ Full Default Configuration # a collection of string functions string_functions: # example - # test_string: Acme\HelloBundle\DQL\StringFunction + # test_string: App\Bridge\Doctrine\DQL\StringFunction # a collection of numeric functions numeric_functions: # example - # test_numeric: Acme\HelloBundle\DQL\NumericFunction + # test_numeric: App\Bridge\Doctrine\DQL\NumericFunction # a collection of datetime functions datetime_functions: # example - # test_datetime: Acme\HelloBundle\DQL\DatetimeFunction + # test_datetime: App\Bridge\Doctrine\DQL\DatetimeFunction # Register SQL Filters in the entity manager filters: @@ -184,7 +184,7 @@ Full Default Configuration .. code-block:: xml - + @@ -219,7 +219,7 @@ Full Default Configuration string - Acme\HelloBundle\MyCustomType + App\Bridge\Doctrine\DBAL\MyCustomType - Acme\HelloBundle\DQL\StringFunction + App\Bridge\Doctrine\DQL\StringFunction - Acme\HelloBundle\DQL\NumericFunction + App\Bridge\Doctrine\DQL\NumericFunction - Acme\HelloBundle\DQL\DatetimeFunction + App\Bridge\Doctrine\DQL\DatetimeFunction @@ -301,7 +301,7 @@ The following block shows all possible configuration keys: password: secret driver: pdo_mysql # the DBAL driverClass option - driver_class: MyNamespace\MyDriverImpl + driver_class: App\Bridge\Doctrine\DBAL\MyDatabaseDriver # the DBAL driverOptions option options: foo: bar @@ -309,15 +309,15 @@ The following block shows all possible configuration keys: memory: true unix_socket: /tmp/mysql.sock # the DBAL wrapperClass option - wrapper_class: MyDoctrineDbalConnectionWrapper + wrapper_class: App\Bridge\Doctrine\DBAL\MyConnectionWrapper charset: UTF8 logging: '%kernel.debug%' - platform_service: MyOwnDatabasePlatformService + platform_service: App\Bridge\Doctrine\DBAL\MyDatabasePlatformService server_version: 5.6 mapping_types: enum: string types: - custom: Acme\HelloBundle\MyCustomType + custom: App\Bridge\Doctrine\DBAL\MyCustomType .. code-block:: xml @@ -339,19 +339,19 @@ The following block shows all possible configuration keys: user="user" password="secret" driver="pdo_mysql" - driver-class="MyNamespace\MyDriverImpl" + driver-class="App\Bridge\Doctrine\DBAL\MyDatabaseDriver" path="%kernel.project_dir%/var/data/data.sqlite" memory="true" unix-socket="/tmp/mysql.sock" - wrapper-class="MyDoctrineDbalConnectionWrapper" + wrapper-class="App\Bridge\Doctrine\DBAL\MyConnectionWrapper" charset="UTF8" logging="%kernel.debug%" - platform-service="MyOwnDatabasePlatformService" + platform-service="App\Bridge\Doctrine\DBAL\MyDatabasePlatformService" server-version="5.6"> bar string - Acme\HelloBundle\MyCustomType + App\Bridge\Doctrine\DBAL\MyCustomType @@ -480,7 +480,7 @@ The following example shows an overview of the caching configurations: # the 'service' type requires to define the 'id' option too query_cache_driver: type: service - id: my_doctrine_common_cache_service + id: App\Bridge\Doctrine\ORM\MyCacheService Mapping Configuration ~~~~~~~~~~~~~~~~~~~~~ @@ -662,7 +662,7 @@ If the ``type`` on the bundle configuration isn't set, the DoctrineBundle will try to detect the correct mapping configuration format for the bundle. DoctrineBundle will look for files matching ``*.orm.[FORMAT]`` (e.g. -``Post.orm.yml``) in the configured ``dir`` of your mapping (if you're mapping +``Post.orm.yaml``) in the configured ``dir`` of your mapping (if you're mapping a bundle, then ``dir`` is relative to the bundle's directory). The bundle looks for (in this order) XML, YAML and PHP files. diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 374edd23263..af484a46ea1 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -180,7 +180,7 @@ named ``kernel.http_method_override``. To fix this, invoke the ``enableHttpMethodParameterOverride()`` method before creating the ``Request`` object:: - // web/app.php + // public/index.php // ... $kernel = new AppCache($kernel); @@ -220,13 +220,13 @@ doubling them to prevent Symfony from interpreting them as container parameters) .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: ide: 'myide://open?url=file://%%f&line=%%l' .. code-block:: xml - + loadFromExtension('framework', array( 'ide' => 'myide://open?url=file://%%f&line=%%l', )); @@ -283,7 +283,7 @@ test If this configuration setting is present (and not ``false``), then the services related to testing your application (e.g. ``test.client``) are loaded. This setting should be present in your ``test`` environment (usually via -``app/config/config_test.yml``). +``config/packages/test/framework.yaml``). .. seealso:: @@ -334,13 +334,13 @@ respond and the user will receive a 400 response. .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: trusted_hosts: ['example.com', 'example.org'] .. code-block:: xml - + loadFromExtension('framework', array( 'trusted_hosts' => array('example.com', 'example.org'), )); @@ -369,7 +369,7 @@ which make it easier to respond to any subdomain. In addition, you can also set the trusted hosts in the front controller using the ``Request::setTrustedHosts()`` method:: - // web/app.php + // public/index.php Request::setTrustedHosts(array('^(.+\.)?example.com$', '^(.+\.)?example.org$')); The default value for this option is an empty array, meaning that the application @@ -450,13 +450,13 @@ You can also set ``esi`` to ``true`` to enable it: .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: esi: true .. code-block:: xml - + loadFromExtension('framework', array( 'esi' => true, )); @@ -592,7 +592,7 @@ To configure a ``jsonp`` format: .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: request: formats: @@ -600,7 +600,7 @@ To configure a ``jsonp`` format: .. code-block:: xml - + loadFromExtension('framework', array( 'request' => array( 'formats' => array( @@ -824,14 +824,14 @@ setting the value to ``null``: .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: session: save_path: ~ .. code-block:: xml - + loadFromExtension('framework', array( 'session' => array( 'save_path' => null, @@ -883,7 +883,7 @@ This option allows you to define a base path to be used for assets: .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: # ... assets: @@ -891,7 +891,7 @@ This option allows you to define a base path to be used for assets: .. code-block:: xml - + loadFromExtension('framework', array( // ... 'assets' => array( @@ -931,7 +931,7 @@ collection each time it generates an asset's path: .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: # ... assets: @@ -940,7 +940,7 @@ collection each time it generates an asset's path: .. code-block:: xml - + loadFromExtension('framework', array( // ... 'assets' => array( @@ -975,7 +975,7 @@ You can group assets into packages, to specify different base URLs for them: .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: # ... assets: @@ -985,7 +985,7 @@ You can group assets into packages, to specify different base URLs for them: .. code-block:: xml - + loadFromExtension('framework', array( // ... 'assets' => array( @@ -1070,7 +1070,7 @@ Now, activate the ``version`` option: .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: # ... assets: @@ -1078,7 +1078,7 @@ Now, activate the ``version`` option: .. code-block:: xml - + loadFromExtension('framework', array( // ... 'assets' => array( @@ -1175,7 +1175,7 @@ individually for each asset package: .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: assets: # this strategy is applied to every asset (including packages) @@ -1193,7 +1193,7 @@ individually for each asset package: .. code-block:: xml - + loadFromExtension('framework', array( 'assets' => array( 'version_strategy' => 'app.asset.my_versioning_strategy', @@ -1273,7 +1273,7 @@ package: .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: assets: # this manifest is applied to every asset (including packages) @@ -1288,7 +1288,7 @@ package: .. code-block:: xml - + loadFromExtension('framework', array( 'assets' => array( // this manifest is applied to every asset (including packages) @@ -1372,13 +1372,13 @@ if you're using the Twig format for your templates, in that case refer to :ref:`the form article `. Assume you have custom global form themes in -``src/WebsiteBundle/Resources/views/Form``, you can configure this like: +``src/Resources/views/Form``, you can configure this like: .. configuration-block:: .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: templating: form: @@ -1387,7 +1387,7 @@ Assume you have custom global form themes in .. code-block:: xml - + loadFromExtension('framework', array( 'templating' => array( 'form' => array( diff --git a/reference/configuration/kernel.rst b/reference/configuration/kernel.rst index 63d4ee42af6..3a1adc0c594 100644 --- a/reference/configuration/kernel.rst +++ b/reference/configuration/kernel.rst @@ -1,11 +1,11 @@ .. index:: single: Configuration reference; Kernel class -Configuring in the Kernel (e.g. AppKernel) -========================================== +Configuring in the Kernel +========================= -Some configuration can be done on the kernel class itself (usually called -``app/AppKernel.php``). You can do this by overriding specific methods in +Some configuration can be done on the kernel class itself (located by default at +``src/Kernel.php``). You can do this by overriding specific methods in the parent :class:`Symfony\\Component\\HttpKernel\\Kernel` class. Configuration @@ -26,10 +26,11 @@ This returns the charset that is used in the application. To change it, override the :method:`Symfony\\Component\\HttpKernel\\Kernel::getCharset` method and return another charset, for instance:: - // app/AppKernel.php - + // src/Kernel.php + use Symfony\Component\HttpKernel\Kernel as BaseKernel; // ... - class AppKernel extends Kernel + + class Kernel extends BaseKernel { public function getCharset() { @@ -40,18 +41,17 @@ method and return another charset, for instance:: Kernel Name ~~~~~~~~~~~ -**type**: ``string`` **default**: ``app`` (i.e. the directory name holding +**type**: ``string`` **default**: ``src`` (i.e. the directory name holding the kernel class) To change this setting, override the :method:`Symfony\\Component\\HttpKernel\\Kernel::getName` method. Alternatively, move your kernel into a different directory. For -example, if you moved the kernel into a ``foo`` directory (instead of ``app``), +example, if you moved the kernel into a ``foo/`` directory (instead of ``src/``), the kernel name will be ``foo``. The name of the kernel isn't usually directly important - it's used in the -generation of cache files. If you have an application with multiple kernels, -the easiest way to make each have a unique name is to duplicate the ``app`` -directory and rename it to something else (e.g. ``foo``). +generation of cache files - and you probably will only change it when +:doc:`using applications with multiple kernels `. Project Directory ~~~~~~~~~~~~~~~~~ @@ -65,10 +65,11 @@ If for some reason the ``composer.json`` file is not stored at the root of your project, you can override the :method:`Symfony\\Component\\HttpKernel\\Kernel::getProjectDir` method to return the right project directory:: - // app/AppKernel.php - + // src/Kernel.php + use Symfony\Component\HttpKernel\Kernel as BaseKernel; // ... - class AppKernel extends Kernel + + class Kernel extends BaseKernel { // ... diff --git a/reference/configuration/monolog.rst b/reference/configuration/monolog.rst index a067d95bc10..c2db56b574d 100644 --- a/reference/configuration/monolog.rst +++ b/reference/configuration/monolog.rst @@ -14,7 +14,7 @@ Full Default Configuration .. code-block:: yaml - # app/config/config.yml + # config/packages/monolog.yaml monolog: handlers: @@ -77,7 +77,7 @@ Full Default Configuration .. code-block:: xml - + + loadFromExtension('security', array( 'firewalls' => array( 'somename' => array( diff --git a/reference/configuration/swiftmailer.rst b/reference/configuration/swiftmailer.rst index 2bf47c40859..a1b06c2af80 100644 --- a/reference/configuration/swiftmailer.rst +++ b/reference/configuration/swiftmailer.rst @@ -193,10 +193,11 @@ delivery_addresses In previous versions, this option was called ``delivery_address``. -If set, all email messages will be sent to these addresses instead of being -sent to their actual recipients. This is often useful when developing. For -example, by setting this in the ``config_dev.yml`` file, you can guarantee -that all emails sent during development go to one or more some specific accounts. +If set, all email messages will be sent to these addresses instead of being sent +to their actual recipients. This is often useful when developing. For example, +by setting this in the ``config/packages/dev/swiftmailer.yaml`` file, you can +guarantee that all emails sent during development go to one or more some +specific accounts. This uses ``Swift_Plugins_RedirectingPlugin``. Original recipients are available on the ``X-Swift-To``, ``X-Swift-Cc`` and ``X-Swift-Bcc`` headers. diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index c5c2a0acf54..5f132fcdbc7 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -8,7 +8,7 @@ TwigBundle Configuration ("twig") .. code-block:: yaml - # app/config/config.yml + # config/packages/twig.yaml twig: exception_controller: twig.controller.exception:showAction @@ -70,7 +70,7 @@ TwigBundle Configuration ("twig") .. code-block:: xml - + loadFromExtension('twig', array( 'form_themes' => array( 'form_div_layout.html.twig', // Default @@ -365,7 +365,7 @@ The values of the ``paths`` option are defined as ``key: value`` pairs where the .. code-block:: yaml - # app/config/config.yml + # config/packages/twig.yaml twig: # ... paths: @@ -373,7 +373,7 @@ The values of the ``paths`` option are defined as ``key: value`` pairs where the .. code-block:: xml - + loadFromExtension('twig', array( // ... 'paths' => array( @@ -409,7 +409,7 @@ for that directory: .. code-block:: yaml - # app/config/config.yml + # config/packages/twig.yaml twig: # ... paths: @@ -417,7 +417,7 @@ for that directory: .. code-block:: xml - + loadFromExtension('twig', array( // ... 'paths' => array( diff --git a/reference/configuration/web_profiler.rst b/reference/configuration/web_profiler.rst index 2943b476cb6..0c1dfe492d0 100644 --- a/reference/configuration/web_profiler.rst +++ b/reference/configuration/web_profiler.rst @@ -58,7 +58,7 @@ Full Default Configuration .. code-block:: yaml - # app/config/config.yml + # config/packages/dev/web_profiler.yaml web_profiler: toolbar: false intercept_redirects: false @@ -66,7 +66,7 @@ Full Default Configuration .. code-block:: xml - + - - - - - - - - - - .. code-block:: php - - use App\Assetic\CustomWorker; - - $container - ->register(CustomWorker::class) - ->addTag('assetic.factory_worker') - ; - -assetic.filter --------------- - -**Purpose**: Register a filter - -AsseticBundle uses this tag to register common filters. You can also use -this tag to register your own filters. - -First, you need to create a filter:: - - use Assetic\Asset\AssetInterface; - use Assetic\Filter\FilterInterface; - - class MyFilter implements FilterInterface - { - public function filterLoad(AssetInterface $asset) - { - $asset->setContent('alert("yo");' . $asset->getContent()); - } - - public function filterDump(AssetInterface $asset) - { - // ... - } - } - -Second, define a service: - -.. configuration-block:: - - .. code-block:: yaml - - services: - App\Assetic\CustomFilter: - tags: - - { name: assetic.filter, alias: my_filter } - - .. code-block:: xml - - - - - - - - - - - - .. code-block:: php - - use App\Assetic\CustomFilter; - - $container - ->register(CustomFilter::class) - ->addTag('assetic.filter', array('alias' => 'my_filter')) - ; - -Finally, apply the filter: - -.. code-block:: twig - - {% javascripts - '@AcmeBaseBundle/Resources/public/js/global.js' - filter='my_filter' - %} - - {% endjavascripts %} - -You can also apply your filter via the ``assetic.filters.my_filter.apply_to`` -config option as it's described here: :doc:`/frontend/assetic/apply_to_option`. -In order to do that, you must define your filter service in a separate xml -config file and point to this file's path via the ``assetic.filters.my_filter.resource`` -configuration key. - -assetic.formula_loader ----------------------- - -**Purpose**: Add a formula loader to the current asset manager - -A Formula loader is a class implementing -``Assetic\\Factory\Loader\\FormulaLoaderInterface`` interface. This class -is responsible for loading assets from a particular kind of resources (for -instance, twig template). Assetic ships loaders for PHP and Twig templates. - -An ``alias`` attribute defines the name of the loader. - -assetic.formula_resource ------------------------- - -**Purpose**: Adds a resource to the current asset manager - -A resource is something formulae can be loaded from. For instance, Twig -templates are resources. - -assetic.templating.php ----------------------- - -**Purpose**: Remove this service if PHP templating is disabled - -The tagged service will be removed from the container if the -``framework.templating.engines`` config section does not contain php. - -assetic.templating.twig ------------------------ - -**Purpose**: Remove this service if Twig templating is disabled - -The tagged service will be removed from the container if -``framework.templating.engines`` config section does not contain ``twig``. - auto_alias ---------- @@ -513,7 +330,7 @@ is generated dynamically. To register your own cache warmer, first create a service that implements the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` interface:: - // src/Acme/MainBundle/Cache/MyCustomWarmer.php + // src/Cache/MyCustomWarmer.php namespace App\Cache; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; diff --git a/reference/forms/types/entity.rst b/reference/forms/types/entity.rst index 4be56046084..6945ee1b4e3 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -173,7 +173,7 @@ more details, see the main :ref:`choice_label ` doc // ... $builder->add('genre', EntityType::class, array( - 'class' => 'MyBundle:Genre', + 'class' => 'App\Entity\Genre', 'choice_label' => 'translations[en].name', )); diff --git a/reference/map.rst.inc b/reference/map.rst.inc index 8339192ab96..cfc67ca0832 100644 --- a/reference/map.rst.inc +++ b/reference/map.rst.inc @@ -1,7 +1,7 @@ * **Configuration Options** Ever wondered what configuration options you have available to you in - files such as ``app/config/config.yml``? In this section, all the available + ``config/packages/*.yaml`` files? In this section, all the available configuration is broken down by the key (e.g. ``framework``) that defines each possible section of your Symfony configuration. From ef2a0449cf58558269f7777cda07bb7579bdefdc Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 24 Nov 2017 15:53:38 +0100 Subject: [PATCH 2/5] Remove App\Bridge\Doctrine\ namespace --- reference/configuration/doctrine.rst | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index d5d8efd97e8..a21e77ad6ed 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -20,7 +20,7 @@ Full Default Configuration # A collection of custom types # Example some_custom_type: - class: App\Bridge\Doctrine\DBAL\MyCustomType + class: App\DBAL\MyCustomType commented: true @@ -163,17 +163,17 @@ Full Default Configuration # a collection of string functions string_functions: # example - # test_string: App\Bridge\Doctrine\DQL\StringFunction + # test_string: App\DQL\StringFunction # a collection of numeric functions numeric_functions: # example - # test_numeric: App\Bridge\Doctrine\DQL\NumericFunction + # test_numeric: App\DQL\NumericFunction # a collection of datetime functions datetime_functions: # example - # test_datetime: App\Bridge\Doctrine\DQL\DatetimeFunction + # test_datetime: App\DQL\DatetimeFunction # Register SQL Filters in the entity manager filters: @@ -204,14 +204,14 @@ Full Default Configuration user="user" password="secret" driver="pdo_mysql" - driver-class="App\Bridge\Doctrine\DBAL\MyDatabaseDriver" + driver-class="App\DBAL\MyDatabaseDriver" path="%kernel.project_dir%/var/data/data.sqlite" memory="true" unix-socket="/tmp/mysql.sock" - wrapper-class="App\Bridge\Doctrine\DBAL\MyConnectionWrapper" + wrapper-class="App\DBAL\MyConnectionWrapper" charset="UTF8" logging="%kernel.debug%" - platform-service="App\Bridge\Doctrine\DBAL\MyDatabasePlatformService" + platform-service="App\DBAL\MyDatabasePlatformService" server-version="5.6" keep-slave="false" > @@ -219,7 +219,7 @@ Full Default Configuration string - App\Bridge\Doctrine\DBAL\MyCustomType + App\DBAL\MyCustomType - App\Bridge\Doctrine\DQL\StringFunction + App\DQL\StringFunction - App\Bridge\Doctrine\DQL\NumericFunction + App\DQL\NumericFunction - App\Bridge\Doctrine\DQL\DatetimeFunction + App\DQL\DatetimeFunction @@ -301,7 +301,7 @@ The following block shows all possible configuration keys: password: secret driver: pdo_mysql # the DBAL driverClass option - driver_class: App\Bridge\Doctrine\DBAL\MyDatabaseDriver + driver_class: App\DBAL\MyDatabaseDriver # the DBAL driverOptions option options: foo: bar @@ -309,15 +309,15 @@ The following block shows all possible configuration keys: memory: true unix_socket: /tmp/mysql.sock # the DBAL wrapperClass option - wrapper_class: App\Bridge\Doctrine\DBAL\MyConnectionWrapper + wrapper_class: App\DBAL\MyConnectionWrapper charset: UTF8 logging: '%kernel.debug%' - platform_service: App\Bridge\Doctrine\DBAL\MyDatabasePlatformService + platform_service: App\DBAL\MyDatabasePlatformService server_version: 5.6 mapping_types: enum: string types: - custom: App\Bridge\Doctrine\DBAL\MyCustomType + custom: App\DBAL\MyCustomType .. code-block:: xml @@ -339,19 +339,19 @@ The following block shows all possible configuration keys: user="user" password="secret" driver="pdo_mysql" - driver-class="App\Bridge\Doctrine\DBAL\MyDatabaseDriver" + driver-class="App\DBAL\MyDatabaseDriver" path="%kernel.project_dir%/var/data/data.sqlite" memory="true" unix-socket="/tmp/mysql.sock" - wrapper-class="App\Bridge\Doctrine\DBAL\MyConnectionWrapper" + wrapper-class="App\DBAL\MyConnectionWrapper" charset="UTF8" logging="%kernel.debug%" - platform-service="App\Bridge\Doctrine\DBAL\MyDatabasePlatformService" + platform-service="App\DBAL\MyDatabasePlatformService" server-version="5.6"> bar string - App\Bridge\Doctrine\DBAL\MyCustomType + App\DBAL\MyCustomType @@ -480,7 +480,7 @@ The following example shows an overview of the caching configurations: # the 'service' type requires to define the 'id' option too query_cache_driver: type: service - id: App\Bridge\Doctrine\ORM\MyCacheService + id: App\ORM\MyCacheService Mapping Configuration ~~~~~~~~~~~~~~~~~~~~~ From e80995b979dd8a3ee7c8a126ab3f77882401f3ff Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 24 Nov 2017 15:55:56 +0100 Subject: [PATCH 3/5] Fixed PHP form theme resources --- reference/configuration/framework.rst | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index af484a46ea1..58602365003 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -1371,8 +1371,8 @@ A list of all resources for form theming in PHP. This setting is not required if you're using the Twig format for your templates, in that case refer to :ref:`the form article `. -Assume you have custom global form themes in -``src/Resources/views/Form``, you can configure this like: +Assume you have custom global form themes in ``templates/form_themes/``, you can +configure this like: .. configuration-block:: @@ -1383,7 +1383,7 @@ Assume you have custom global form themes in templating: form: resources: - - 'WebsiteBundle:Form' + - 'form_themes' .. code-block:: xml @@ -1397,17 +1397,11 @@ Assume you have custom global form themes in http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - - - - WebsiteBundle:Form - + form_themes - - @@ -1418,7 +1412,7 @@ Assume you have custom global form themes in 'templating' => array( 'form' => array( 'resources' => array( - 'WebsiteBundle:Form' + 'form_themes' ), ), ), From 206bf70c45e4b992c664c40efe3a5146e95fd6d2 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 24 Nov 2017 16:12:49 +0100 Subject: [PATCH 4/5] Updated Doctrine config reference about bundles --- reference/configuration/doctrine.rst | 35 +++++++++++----------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index a21e77ad6ed..5c5ea0c5b48 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -492,42 +492,35 @@ you can control. The following configuration options exist for a mapping: type .... -One of ``annotation``, ``xml``, ``yml``, ``php`` or ``staticphp``. This -specifies which type of metadata type your mapping uses. +One of ``annotation`` (the default value), ``xml``, ``yml``, ``php`` or +``staticphp``. This specifies which type of metadata type your mapping uses. dir ... -Path to the mapping or entity files (depending on the driver). If this path -is relative it is assumed to be relative to the bundle root. This only works -if the name of your mapping is a bundle name. If you want to use this option -to specify absolute paths you should prefix the path with the kernel parameters -that exist in the DIC (for example ``%kernel.project_dir%``). +Absolute path to the mapping or entity files (depending on the driver). The +default value is ``%kernel.project_dir%/src/Entity/``. prefix ...... -A common namespace prefix that all entities of this mapping share. This -prefix should never conflict with prefixes of other defined mappings otherwise -some of your entities cannot be found by Doctrine. This option defaults -to the bundle namespace + ``Entity``, for example for an application bundle -called AcmeHelloBundle prefix would be ``Acme\HelloBundle\Entity``. +A common namespace prefix that all entities of this mapping share. This prefix +should never conflict with prefixes of other defined mappings otherwise some of +your entities cannot be found by Doctrine. This option defaults to +``App\Entity`` because it's recommended to store the entities in ``src/Entity/``. alias ..... Doctrine offers a way to alias entity namespaces to simpler, shorter names -to be used in DQL queries or for Repository access. When using a bundle -the alias defaults to the bundle name. +to be used in DQL queries or for Repository access. It's default value is ``App``. is_bundle ......... -This option is a derived value from ``dir`` and by default is set to ``true`` -if dir is relative proved by a ``file_exists()`` check that returns ``false``. -It is ``false`` if the existence check returns ``true``. In this case an -absolute path was specified and the metadata files are most likely in a -directory outside of a bundle. +This option is ``false`` by default and it's considered a legacy option. It was +only useful in previous Symfony versions, when it was recommended to use bundles +to organize the application code. Custom Mapping Entities in a Bundle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -593,9 +586,7 @@ directory instead: Mapping Entities Outside of a Bundle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -You can also create new mappings, for example outside of the Symfony folder. - -For example, the following looks for entity classes in the ``App\Entity`` +For example, the following looks for entity classes in the ``Entity`` namespace in the ``src/Entity`` directory and gives them an ``App`` alias (so you can say things like ``App:Post``): From f7090351f424db813f900f2ad0ce414fe6525977 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 27 Nov 2017 11:39:03 +0100 Subject: [PATCH 5/5] Restored the Assetic tags because they are removed in another PR --- reference/dic_tags.rst | 183 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 9f7cdc72e12..d234f9777d7 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -15,6 +15,13 @@ may also be tags in other bundles you use that aren't listed here. ======================================== ======================================================================== Tag Name Usage ======================================== ======================================================================== +`assetic.asset`_ Register an asset to the current asset manager +`assetic.factory_worker`_ Add a factory worker +`assetic.filter`_ Register a filter +`assetic.formula_loader`_ Add a formula loader to the current asset manager +`assetic.formula_resource`_ Adds a resource to the current asset manager +`assetic.templating.php`_ Remove this service if PHP templating is disabled +`assetic.templating.twig`_ Remove this service if Twig templating is disabled `auto_alias`_ Define aliases based on the value of container parameters `console.command`_ Add a command `controller.argument_value_resolver`_ Register a value resolver for controller arguments such as ``Request`` @@ -49,6 +56,182 @@ Tag Name Usage `validator.initializer`_ Register a service that initializes objects before validation ======================================== ======================================================================== +assetic.asset +------------- + +**Purpose**: Register an asset with the current asset manager + +assetic.factory_worker +---------------------- + +**Purpose**: Add a factory worker + +A Factory worker is a class implementing ``Assetic\Factory\Worker\WorkerInterface``. +Its ``process($asset)`` method is called for each asset after asset creation. +You can modify an asset or even return a new one. + +In order to add a new worker, first create a class:: + + use Assetic\Asset\AssetInterface; + use Assetic\Factory\Worker\WorkerInterface; + + class MyWorker implements WorkerInterface + { + public function process(AssetInterface $asset) + { + // ... change $asset or return a new one + } + + } + +And then register it as a tagged service: + +.. configuration-block:: + + .. code-block:: yaml + + services: + App\Assetic\CustomWorker: + tags: [assetic.factory_worker] + + .. code-block:: xml + + + + + + + + + + + + .. code-block:: php + + use App\Assetic\CustomWorker; + + $container + ->register(CustomWorker::class) + ->addTag('assetic.factory_worker') + ; + +assetic.filter +-------------- + +**Purpose**: Register a filter + +AsseticBundle uses this tag to register common filters. You can also use +this tag to register your own filters. + +First, you need to create a filter:: + + use Assetic\Asset\AssetInterface; + use Assetic\Filter\FilterInterface; + + class MyFilter implements FilterInterface + { + public function filterLoad(AssetInterface $asset) + { + $asset->setContent('alert("yo");' . $asset->getContent()); + } + + public function filterDump(AssetInterface $asset) + { + // ... + } + } + +Second, define a service: + +.. configuration-block:: + + .. code-block:: yaml + + services: + App\Assetic\CustomFilter: + tags: + - { name: assetic.filter, alias: my_filter } + + .. code-block:: xml + + + + + + + + + + + + .. code-block:: php + + use App\Assetic\CustomFilter; + + $container + ->register(CustomFilter::class) + ->addTag('assetic.filter', array('alias' => 'my_filter')) + ; + +Finally, apply the filter: + +.. code-block:: twig + + {% javascripts + '@AcmeBaseBundle/Resources/public/js/global.js' + filter='my_filter' + %} + + {% endjavascripts %} + +You can also apply your filter via the ``assetic.filters.my_filter.apply_to`` +config option as it's described here: :doc:`/frontend/assetic/apply_to_option`. +In order to do that, you must define your filter service in a separate xml +config file and point to this file's path via the ``assetic.filters.my_filter.resource`` +configuration key. + +assetic.formula_loader +---------------------- + +**Purpose**: Add a formula loader to the current asset manager + +A Formula loader is a class implementing +``Assetic\\Factory\Loader\\FormulaLoaderInterface`` interface. This class +is responsible for loading assets from a particular kind of resources (for +instance, twig template). Assetic ships loaders for PHP and Twig templates. + +An ``alias`` attribute defines the name of the loader. + +assetic.formula_resource +------------------------ + +**Purpose**: Adds a resource to the current asset manager + +A resource is something formulae can be loaded from. For instance, Twig +templates are resources. + +assetic.templating.php +---------------------- + +**Purpose**: Remove this service if PHP templating is disabled + +The tagged service will be removed from the container if the +``framework.templating.engines`` config section does not contain php. + +assetic.templating.twig +----------------------- + +**Purpose**: Remove this service if Twig templating is disabled + +The tagged service will be removed from the container if +``framework.templating.engines`` config section does not contain ``twig``. + auto_alias ----------