Skip to content
Permalink
Browse files

feature #31975 Dynamic bundle assets (garak)

This PR was squashed before being merged into the 4.4 branch (closes #31975).

Discussion
----------

Dynamic bundle assets

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no (new method in interface as annotation)
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29213
| License       | MIT
| Doc PR        | none (yet)

Everything is explained in linked issue

Commits
-------

c16fcc9 Dynamic bundle assets
  • Loading branch information...
fabpot committed Jul 9, 2019
2 parents 4a50400 + c16fcc9 commit de710f6640317342dc9a845a37a328a2fb9cf318
@@ -137,7 +137,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
$validAssetDirs = [];
/** @var BundleInterface $bundle */
foreach ($kernel->getBundles() as $bundle) {
if (!is_dir($originDir = $bundle->getPath().'/Resources/public')) {
if (!method_exists($bundle, 'getPublicPath')) {
@trigger_error('Not defining "getPublicPath()" method is deprecated since Symfony 4.4 and will not be supported in 5.0.', E_USER_DEPRECATED);
$publicPath = 'Resources/public';
} else {
$publicPath = $bundle->getPublicPath();
}
if (!is_dir($originDir = $bundle->getPath().\DIRECTORY_SEPARATOR.$publicPath)) {
continue;
}
@@ -135,6 +135,11 @@ public function registerCommands(Application $application)
{
}
public function getPublicPath(): string
{
return 'Resources/public';
}
/**
* Returns the bundle's container extension class.
*
@@ -19,6 +19,8 @@
* BundleInterface.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @method string getPublicPath() Returns relative path for public assets
*/
interface BundleInterface extends ContainerAwareInterface
{
@@ -627,7 +627,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
{
$bundle = $this
->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')
->setMethods(['getPath', 'getParent', 'getName'])
->setMethods(['getPath', 'getPublicPath', 'getParent', 'getName'])
->disableOriginalConstructor()
;
@@ -649,6 +649,12 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
->willReturn($dir)
;
$bundle
->expects($this->any())
->method('getPublicPath')
->willReturn('Resources/public')
;
$bundle
->expects($this->any())
->method('getParent')

0 comments on commit de710f6

Please sign in to comment.
You can’t perform that action at this time.