Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #30645 Alias for each assets package (gpenverne)
This PR was merged into the 4.3-dev branch. Discussion ---------- Alias for each assets package | Q | A | ------------- | --- | Branch? | master <!-- see below --> | Bug fix? | no | New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | ? <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | <!-- required for new features --> Add autowiring by type + name on assets packages ```yaml framework: assets: packages: xxx: base_urls: 'xxxx' ``` ```php <?php class MyService { private $xxxPackage; public function __construct(PackageInterface $xxxPackage) { $this->xxxPackage = $xxxPackage; ... } public function myMethod(): string { return $this->xxxPackage->getUrl('some-image.png'); } } ``` instead of: ```php <?php class MyService { private $packages; public function __construct(Packages $packages) { $this->packages = $packages; ... } public function myMethod(): string { return $this->packages->getPackage('xxx')->getUrl('some-image.png'); } } ``` Commits ------- e8b9856 Alias for each assets package
- Loading branch information