Commit Graph

20114 Commits

Author SHA1 Message Date
Fabien Potencier 9a4f3e134b feature #13398 [PhpUnit] new PhpUnit bridge (nicolas-grekas)
This PR was merged into the 2.7 branch.

Discussion
----------

[PhpUnit] new PhpUnit bridge

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #13644
| License       | MIT
| Doc PR        | -

From the proposed README:

PHPUnit Bridge
==============

Provides utilities for PHPUnit, especially user deprecation notices management.

It comes with the following features:

 * disable the garbage collector;
 * auto-register `class_exists` to load Doctrine annotations;
 * print a user deprecation notices summary at the end of the test suite.

Handling user deprecation notices is sensitive to the SYMFONY_DEPRECATIONS_HELPER
environment variable. This env var configures 3 behaviors depending on its value:

 * when set to `strict`, all but legacy-tagged deprecation notices will make tests
   fail. This is the recommended mode for best forward compatibility.
 * `weak` on the contrary will make tests ignore all deprecation notices.
   This is the recommended mode for legacy projects that must use deprecated
   interfaces for backward compatibility reasons.
 * any other value will respect the current error reporting level.

All three modes will display a summary of deprecation notices at the end of the
test suite, split in two groups:

 * **Legacy** deprecation notices denote tests that explicitly test some legacy
   interfaces. In all 3 modes, deprecation notices triggered in a legacy-tagged
   test do never make a test fail. There are four ways to mark a test as legacy:
    - make its class start with the `Legacy` prefix;
    - make its method start with `testLegacy`;
    - make its data provider start with `provideLegacy` or `getLegacy`;
    - add the `@group legacy` annotation to its class or method.
 * **Remaining/Other** deprecation notices are all other (non-legacy)
   notices, grouped by message, test class and method.

Usage
-----

Add this bridge to the `require-dev` section of your composer.json file
(not in `require`) with e.g.
`composer require --dev "symfony/phpunit-bridge"`.

When running `phpunit`, you will see a summary of deprecation notices at the end
of the test suite.

Deprecation notices in the **Remaining/Other** section need some thought.
You have to decide either to:

 * update your code to not use deprecated interfaces anymore, thus gaining better
   forward compatibility;
 * or move them to the **Legacy** section (by using one of the above way).

After reviewing them, you should silence deprecations in the **Legacy** section
if you think they are triggered by tests dedicated to testing deprecated
interfaces. To do so, add the following line at the beginning of your legacy
test case or in the `setUp()` method of your legacy test class:
`$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);`

Last but not least, you should then configure your C.I. to the reporting mode
that is appropriated to your project by setting SYMFONY_DEPRECATIONS_HELPER to
`strict`, `weak` or empty. It is recommended to start with `weak` mode, upgrade
your code as described above, then when the *Remaining/Other* sections are empty,
move to `strict` to keep forward compatibility on the long run.

Commits
-------

acac734 [PhpUnitBridge] new bridge for testing with PHPUnit
2015-02-21 09:37:54 +01:00
Nicolas Grekas acac734d08 [PhpUnitBridge] new bridge for testing with PHPUnit 2015-02-18 11:38:04 +01:00
Fabien Potencier a630d87d57 bug #13711 [FrameworkBundle] Check if templating is enabled. (jakzal)
This PR was merged into the 2.7 branch.

Discussion
----------

[FrameworkBundle] Check if templating is enabled.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #13710
| License       | MIT
| Doc PR        | -

templating can be disabled.

Commits
-------

c75b276 [FrameworkBundle] Check if templating is enabled.
2015-02-17 12:55:01 +01:00
Jakub Zalas c75b276a17 [FrameworkBundle] Check if templating is enabled. 2015-02-17 11:00:18 +00:00
Fabien Potencier f44eef4525 minor #13672 [FrameworkBundle] Enable assets by default (jakzal)
This PR was merged into the 2.7 branch.

Discussion
----------

[FrameworkBundle] Enable assets by default

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #13667
| License       | MIT
| Doc PR        | -

This should make the tests pass again.

There are two templates from TwigBundle that are used with functional tests, and require the asset() helper:
* src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig
* src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig

Commits
-------

f5c0a69 [FrameworkBundle] Enable assets by default.
2015-02-16 10:20:28 +01:00
Fabien Potencier 3bbca21630 minor #13692 [Filesystem] Improve exception message for copy method (King2500)
This PR was submitted for the 2.6 branch but it was merged into the 2.7 branch instead (closes #13692).

Discussion
----------

[Filesystem] Improve exception message for copy method

see diff

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes? (no change in semantics)
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

021206c [Filesystem] Improve exception message for copy method
2015-02-16 10:13:40 +01:00
Thomas Schulz 021206c0ac [Filesystem] Improve exception message for copy method 2015-02-16 10:13:25 +01:00
Fabien Potencier 4c767e64b2 feature #13615 [FrameworkBundle] Made ServerParams a service (rpg600)
This PR was submitted for the 2.5 branch but it was merged into the 2.7 branch instead (closes #13615).

Discussion
----------

[FrameworkBundle] Made ServerParams a service

| Q             | A
| ------------- | ---
| Bug fix?      | [yes]
| New feature?  | [no]
| BC breaks?    | [no]
| Deprecations? | [no]
| Tests pass?   | [yes]
| License       | MIT

Since 2.5 we can inject the request stack in ServerParams (see #10912).
Now when a request is handled by HttpFoundationRequestHandler, the content length will be fetched via the current request and not the super global anymore.

Commits
-------

455b714 [FrameworkBundle] Made ServerParams a service
2015-02-16 10:06:55 +01:00
rpg600 455b71419d [FrameworkBundle] Made ServerParams a service 2015-02-16 10:06:54 +01:00
Fabien Potencier baf13c1e32 minor #13701 [2.7] [FrameworkBundle] bugfix in configuration for assets (phansys)
This PR was merged into the 2.7 branch.

Discussion
----------

[2.7] [FrameworkBundle] bugfix in configuration for assets

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

If both of configurations are defined, the exception breaks because it isn't
defined properly (missing backslash in FQCN for ```\LogicException```).
Also, the message was wrong (it's referred to "templating.templating" instead of
"framework.templating").

Commits
-------

3b4c23f [2.7] [FrameworkBundle] bugfix in configuration for assets
2015-02-16 10:04:36 +01:00
Javier Spagnoletti 3b4c23fa16 [2.7] [FrameworkBundle] bugfix in configuration for assets
| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

If both of configurations are defined, the exception is break because it isn't
defined properly (missing backslash in FQCN for ```\LogicException```).
Also, the message was wrong (it's referred to "templating.templating" instead of
"framework.templating").
2015-02-15 18:48:32 -03:00
Jakub Zalas f5c0a6918a [FrameworkBundle] Enable assets by default. 2015-02-15 21:17:25 +00:00
Fabien Potencier 6d52112743 minor #13679 [Form] OptionsResolver 3.0 is not BC anymore (nicolas-grekas)
This PR was merged into the 2.7 branch.

Discussion
----------

[Form] OptionsResolver 3.0 is not BC anymore

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

a0af484 [Form] OptionsResolver 3.0 is not BC anymore
2015-02-13 10:50:36 +01:00
Fabien Potencier 3dfb539607 minor #13677 [TwigBundle] add missing asset dependency (nicolas-grekas)
This PR was merged into the 2.7 branch.

Discussion
----------

[TwigBundle] add missing asset dependency

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

2aead65 [TwigBundle] add missing asset dependency
2015-02-13 10:49:48 +01:00
Nicolas Grekas a0af4843e4 [Form] OptionsResolver 3.0 is not BC anymore 2015-02-13 09:21:53 +01:00
Nicolas Grekas 2aead657b1 [TwigBundle] add missing asset dependency 2015-02-13 08:56:37 +01:00
Fabien Potencier 2d48266f6f feature #12526 Add an auto_alias compiler pass (Daniel Wehner)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #12526).

Discussion
----------

Add an auto_alias compiler pass

Discussion see https://github.com/symfony/symfony/issues/11460

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | [#11460]
| License       | MIT
| Doc PR        |

Commits
-------

d7432c0 Add an auto_alias compiler pass
2015-02-12 18:47:12 +01:00
Daniel Wehner d7432c0241 Add an auto_alias compiler pass 2015-02-12 18:47:12 +01:00
Fabien Potencier eb4c3da6d1 minor #13670 [TwigBundle] Fix typo in ExtensionPass (stloyd)
This PR was merged into the 2.7 branch.

Discussion
----------

[TwigBundle] Fix typo in ExtensionPass

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Fixed tickets | #13669
| License       | MIT

Commits
-------

3a48d1a [TwigBundle] Fix typo in ExtensionPass
2015-02-12 17:07:17 +01:00
Joseph Bielawski 3a48d1a63c [TwigBundle] Fix typo in ExtensionPass 2015-02-12 16:54:37 +01:00
Fabien Potencier f82fc7684b fixed typo 2015-02-12 14:17:00 +01:00
Fabien Potencier a0a0b05bb5 minor #13667 made the assets optional (fabpot)
This PR was merged into the 2.7 branch.

Discussion
----------

made the assets optional

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Right now, the assets configuration is optional (and the dependency as well on FramewokrBundle), but the asset services and the Asset extension is always loaded. This PR fixes this inconsistency, which will make tests pass again.

Commits
-------

ddf5ac4 made the assets optional
2015-02-12 14:07:11 +01:00
Fabien Potencier 74bdb8f902 feature #13665 [Debug] generalize deprecated interfaces tracking (nicolas-grekas)
This PR was merged into the 2.7 branch.

Discussion
----------

[Debug] generalize deprecated interfaces tracking

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #13544
| License       | MIT
| Doc PR        | -

Commits
-------

a756f5b [Debug] generalize deprecated interfaces tracking
2015-02-12 14:05:35 +01:00
Fabien Potencier ddf5ac4429 made the assets optional 2015-02-12 13:06:55 +01:00
Nicolas Grekas a756f5b8a5 [Debug] generalize deprecated interfaces tracking 2015-02-12 13:00:00 +01:00
Fabien Potencier d61ffa9c63 Merge branch '2.6' into 2.7
* 2.6:
  fixed a test
  [WebProfilerBundle] Fixes event listener attaching error in IE
2015-02-12 12:03:31 +01:00
Fabien Potencier 2cca8617b9 fixed a test 2015-02-12 12:03:23 +01:00
Fabien Potencier fd74507630 feature #13656 removed Propel bridge from Symfony Core (fabpot)
This PR was merged into the 2.7 branch.

Discussion
----------

removed Propel bridge from Symfony Core

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes (people using Propel should add `symfony/propel1-bridge` to their deps)
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #13091
| License       | MIT
| Doc PR        | n/a

Commits
-------

3f4b87d removed Propel bridge from Symfony Core
2015-02-12 09:34:45 +01:00
Fabien Potencier 3f4b87d8c0 removed Propel bridge from Symfony Core 2015-02-11 14:04:03 +01:00
Fabien Potencier 9509fb7f51 minor #13600 [Process] added a deprecation notice (fabpot)
This PR was merged into the 2.7 branch.

Discussion
----------

[Process] added a deprecation notice

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #12703, #12725
| License       | MIT
| Doc PR        | n/a

Commits
-------

a901ca2 [Process] added a deprecation notice
2015-02-11 13:46:36 +01:00
Fabien Potencier 0d4ed2be28 minor #13445 [2.7] Added deprecation warning for get request service in controller (WouterJ)
This PR was squashed before being merged into the 2.7 branch (closes #13445).

Discussion
----------

[2.7] Added deprecation warning for get request service in controller

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes (but well, it's 2.7)
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

becd694 [2.7] Added deprecation warning for get request service in controller
2015-02-11 12:15:18 +01:00
Wouter J becd694968 [2.7] Added deprecation warning for get request service in controller 2015-02-11 12:15:14 +01:00
Fabien Potencier 7af0196d89 feature #13500 [Serializer] Normalizers can serialize collections and scalars (dunglas)
This PR was squashed before being merged into the 2.7 branch (closes #13500).

Discussion
----------

[Serializer] Normalizers can serialize collections and scalars

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT
| Doc PR       | n/a

Currently, the logic for serializing `array` and scalars is hardcoded in the serializer. This is not possible to have a custom serializer normalizing collections. This a big limitation, for instance it's not possible to create an normalizer creating [Hydra collections](http://www.hydra-cg.com/spec/latest/core/#h-collections) for a PHP array.

This PR fix that.

Commits
-------

1cf8eb2 [Serializer] Normalizers can serialize collections and scalars
2015-02-11 11:46:00 +01:00
Kévin Dunglas 1cf8eb2d85 [Serializer] Normalizers can serialize collections and scalars 2015-02-11 11:45:57 +01:00
Fabien Potencier 7356876c33 bug #13636 [WebProfilerBundle] Fixes event listener attaching error in IE (aik099)
This PR was merged into the 2.6 branch.

Discussion
----------

[WebProfilerBundle] Fixes event listener attaching error in IE

I haven't tested the change, because I don't any working Symfony installation at hand. By the looks of changes it should work.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | not sure (do we have JS tests?)
| Fixed tickets | #13447
| License       | MIT
| Doc PR        |

Commits
-------

21693e4 [WebProfilerBundle] Fixes event listener attaching error in IE
2015-02-11 11:38:49 +01:00
Fabien Potencier 1d45ca894b Merge branch '2.6' into 2.7
* 2.6: (21 commits)
  [FrameworkBundle] Fix title and placeholder rendering in php form templates.
  [TwigBridge] Removed duplicated code from TwigRenderer
  [Translator][Logging] implement TranslatorBagInterface.
  RequestDataCollector - small fix
  renamed composer.phar to composer to be consistent with the Symfony docs
  [FrameworkBundle] bumped min version of Routing to 2.3
  removed composer --dev option everywhere
  fixed a test
  [Console] Fixed output bug, if escaped string in a formatted string.
  “console help” ignores --raw option
  Fix form icon position in web profiler
  [Security] Remove ContextListener's onKernelResponse listener as it is used
  Revert "minor #12652 [HttpFoundation] [Hackday] #9942 test: Request::getContent() for null value (skler)"
  Revert "fixed assertion"
  fixed assertion
  [HttpFoundation] [Hackday] #9942 test: Request::getContent() for null value
  fixed URL
  Add reference to documentation in FormEvents phpdocs
  [YAML] Fix one-liners to work with multiple new lines
  Keep "pre" meaning for var_dump quick-and-dirty debug
  ...

Conflicts:
	src/Symfony/Bridge/Twig/composer.json
	src/Symfony/Bundle/FrameworkBundle/composer.json
	src/Symfony/Component/Security/Http/Firewall/ContextListener.php
	src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
2015-02-11 08:17:51 +01:00
Fabien Potencier 38f03bd2f5 Merge branch '2.3' into 2.6
* 2.3:
  [FrameworkBundle] Fix title and placeholder rendering in php form templates.
  RequestDataCollector - small fix
  renamed composer.phar to composer to be consistent with the Symfony docs
  [FrameworkBundle] bumped min version of Routing to 2.3
  removed composer --dev option everywhere
  fixed a test
  [Console] Fixed output bug, if escaped string in a formatted string.
  [Security] Remove ContextListener's onKernelResponse listener as it is used
  Revert "minor #12652 [HttpFoundation] [Hackday] #9942 test: Request::getContent() for null value (skler)"
  Revert "fixed assertion"
  fixed assertion
  [HttpFoundation] [Hackday] #9942 test: Request::getContent() for null value
  fixed URL
  Add reference to documentation in FormEvents phpdocs
  [YAML] Fix one-liners to work with multiple new lines
  Keep "pre" meaning for var_dump quick-and-dirty debug
  [Console][Table] Fix cell padding with multi-byte

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_attributes.html.php
	src/Symfony/Bundle/FrameworkBundle/composer.json
	src/Symfony/Component/Console/Helper/TableHelper.php
2015-02-11 08:12:14 +01:00
Fabien Potencier 917067e940 bug #13647 [FrameworkBundle] Fix title and placeholder rendering in php form templates (jakzal)
This PR was merged into the 2.3 branch.

Discussion
----------

[FrameworkBundle] Fix title and placeholder rendering in php form templates

Small fix for rendering placeholder on widgets in php templates.

| Q             | A |
| ------------- | --- |
| Bug fix?      | yes |
| New feature?  | no |
| BC breaks?    | no |
| Deprecations? | no |
| Tests pass?   | no |
| Fixed tickets | - |
| License       | MIT |
| Doc PR        | - |

This is a test case for #13290, including a fix applied on 2.3, since that's the earliest supported branch the bug exist.

In 2.6 the template is a bit different, and unfortunately I couldn't re-use #13290's fix.

When this is merged into 2.3, and then to 2.6 I think we can also merge #13290.

Commits
-------

f82193d [FrameworkBundle] Fix title and placeholder rendering in php form templates.
2015-02-11 08:05:50 +01:00
Jakub Zalas f82193db99 [FrameworkBundle] Fix title and placeholder rendering in php form templates. 2015-02-10 17:14:04 +00:00
Fabien Potencier a901ca20bd [Process] added a deprecation notice 2015-02-10 18:05:37 +01:00
Alexander Obuhovich 21693e4571 [WebProfilerBundle] Fixes event listener attaching error in IE 2015-02-10 18:33:07 +02:00
Fabien Potencier cad9e0f69d feature #13463 [WebProfilerBundle] Replaced raster PNG icons with vector SVG icons (sgrodzicki)
This PR was merged into the 2.7 branch.

Discussion
----------

[WebProfilerBundle] Replaced raster PNG icons with vector SVG icons

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #13298
| License       | MIT
| Doc PR        | -

Follow up of #13298 : inline svg is supported by the same browsers that support data-uri+svg

Commits
-------

00e3a42 Replaced raster PNG icons with vector SVG icons
2015-02-10 17:23:56 +01:00
Fabien Potencier d0c1c534b2 minor #13638 [TwigBridge] Removed duplicated code from TwigRenderer (hason)
This PR was submitted for the 2.7 branch but it was merged into the 2.6 branch instead (closes #13638).

Discussion
----------

[TwigBridge] Removed duplicated code from TwigRenderer

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

See https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Form/FormRenderer.php#L65-L69

Commits
-------

1a9aca7 [TwigBridge] Removed duplicated code from TwigRenderer
2015-02-10 17:22:44 +01:00
Martin Hasoň 1a9aca7152 [TwigBridge] Removed duplicated code from TwigRenderer 2015-02-10 17:22:35 +01:00
Fabien Potencier 8b12bf967a bug #13608 Fix form icon position in web profiler (sadikoff)
This PR was merged into the 2.6 branch.

Discussion
----------

Fix form icon position in web profiler

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

Form icon in web profiler toolbar moved to the left edge
![pe64g11](https://cloud.githubusercontent.com/assets/213810/6077805/4523c5ba-adfb-11e4-9e8c-61c4940cd7c1.png)

This fix changes icon position to its default value.

Commits
-------

b128439 Fix form icon position in web profiler
2015-02-10 17:18:48 +01:00
Fabien Potencier 85c7195ad7 bug #13642 [Translator][Logging] implement TranslatorBagInterface. (aitboudad)
This PR was merged into the 2.6 branch.

Discussion
----------

[Translator][Logging] implement TranslatorBagInterface.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Fixed tickets  | #13632
| Tests pass?   | yes
| License       | MIT

Commits
-------

dcb2306 [Translator][Logging] implement TranslatorBagInterface.
2015-02-10 15:54:53 +01:00
Fabien Potencier 1adf54b87f fixed deprecation notice 2015-02-10 15:28:31 +01:00
Abdellatif Ait boudad dcb2306d03 [Translator][Logging] implement TranslatorBagInterface. 2015-02-10 13:48:21 +00:00
Fabien Potencier 97cff759ef feature #13234 [Asset] added the component (fabpot)
This PR was merged into the 2.7 branch.

Discussion
----------

[Asset] added the component

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #10973, #11748, #11876, #4883, #12474
| License       | MIT
| Doc PR        | not yet

TODO:

 - [ ] submit documentation PR

The current Asset sub-namespace in Templating has several (major) problems:

 * It does not cover all use cases (see #10973 and #4883 for some example)
 * It has some design issues (relies on the Request instance and so requires the request scope, very coupled with the PHP templating sub-system, see #11748 and #11876)

To decouple this feature and make it reusable in Silex for instance, and to fix the design issues and make it more extensible, I've decided to extract and rework the features provided into a new Asset component.

Basically, this component allows the developer to easily manage asset URLs: versioning, paths, and hosts.

Both the new and the old asset management features are kept in this PR to avoid breaking BC; the old system is of course deprecated and automatically converted to the new one.

Even if the features are quite similar, and besides the flexilibity of the new system, here are some differences:

 * `PathPackage` always prepend the path (even if the given path starts with `/`).
 * Usage is stricter (for instance, `PathPackage` requires a basePath to be passed and `UrlPackage` requires that at least on URL is passed).
 * In the configuration, named packages inherits from the version and version format of the default package by default.
 * It is not possible to override the version when asking for a URL (instead, you can define your own version strategy implementation -- the use cases explained in #6092 are easily implemented this way).
 * It's not possible to generate absolute URLs (see #13264 for a better alternative using composition; so using `absolute_url(asset_path('me.png')) should work)`.

#10973 was about adding shortcuts for bundles, which is a good idea; but given that you rarely reference built-in or third-party bundle assets and because we now have a one-bundle default approach named AppBundle, the same can be achieved with just a simple piece of configuration with the new assets feature:

```yml
framework:
    assets:
        packages:
            app:
                base_path: /bundles/app/
            img:
                base_path: /bundles/app/images/
```

Then:

```jinja
{{ asset('images/me.png', 'app') }}
# /bundles/app/images/me.png

{{ asset('me.png', 'img') }}
# /bundles/app/images/me.png
```

#12474 discussed the possibility to add a version for absolute URL. It's not possible to do that in a generic way as the version strategy involves both the version and the path, which obviously cannot work when the path is an absolute URL already. Instead, one should use the `asset_version` Twig function to add the version manually.

Commits
-------

0750d02 removed usage of the deprecated forms of asset() in the core framework
f74a1f2 renamed asset_path() to asset() and added a BC layer
4d0adea [Asset] added a NullContext class
d33c41d [Asset] added the component
2015-02-10 14:18:49 +01:00
Fabien Potencier 0750d02025 removed usage of the deprecated forms of asset() in the core framework 2015-02-10 13:59:19 +01:00