Skip to content

Commit 11a190f

Browse files
committed
Merge branch 'sw-25250/5.6/fix-plugin-resources' into '5.6'
SW-25250 - Fix plugin resource registration See merge request shopware/5/product/shopware!279
2 parents ebb23cb + 83cf5d1 commit 11a190f

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

UPGRADE-5.6.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
This changelog references changes done in Shopware 5.6 patch versions.
44

5+
## 5.6.6
6+
7+
[View all changes from v5.6.5...v5.6.6](https://github.com/shopware/shopware/compare/v5.6.5...v5.6.6)
8+
9+
### Changes
10+
11+
* Changed `\Shopware\Components\DependencyInjection\Compiler\PluginResourceCompilerPass` to work correctly with multiple plugins
12+
513
## 5.6.5
614

715
[View all changes from v5.6.4...v5.6.5](https://github.com/shopware/shopware/compare/v5.6.4...v5.6.5)

engine/Shopware/Components/DependencyInjection/Compiler/PluginResourceCompilerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function process(ContainerBuilder $container): void
8484
}
8585

8686
if (!$definition->hasTag('shopware.event_listener')) {
87-
return;
87+
continue;
8888
}
8989

9090
$container->setDefinition($plugin->getContainerPrefix() . '.internal.resource_subscriber', $definition);

tests/Unit/Components/Plugin/PluginResourceCompilerPassTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use PHPUnit\Framework\TestCase;
2828
use Shopware\Components\DependencyInjection\Compiler\PluginResourceCompilerPass;
2929
use Shopware\Components\Plugin;
30+
use Shopware\Components\Plugin\ResourceSubscriber;
3031
use Symfony\Component\DependencyInjection\ContainerBuilder;
3132

3233
class PluginResourceCompilerPassTest extends TestCase
@@ -107,4 +108,39 @@ public function testWithEnabledAutoload(): void
107108
// JS, CSS, LESS, FRONTEND TPL, BACKEND TPL
108109
static::assertCount(5, $tags);
109110
}
111+
112+
public function testTwoPlugins(): void
113+
{
114+
$emptyPlugin = $this->createMock(Plugin::class);
115+
$emptyPlugin->method('getPath')
116+
->willReturn(__DIR__ . '/examples/EmptyPlugin');
117+
118+
$emptyPlugin
119+
->method('hasAutoloadViews')
120+
->willReturn(true);
121+
122+
$emptyPlugin
123+
->method('getContainerPrefix')
124+
->willReturn('empty_plugin');
125+
126+
$filledPlugin = $this->createMock(Plugin::class);
127+
$filledPlugin->method('getPath')
128+
->willReturn(__DIR__ . '/examples/TestPlugin');
129+
130+
$filledPlugin
131+
->method('hasAutoloadViews')
132+
->willReturn(true);
133+
134+
$filledPlugin
135+
->method('getContainerPrefix')
136+
->willReturn('filled_plugin');
137+
138+
$container = new ContainerBuilder();
139+
$container->addCompilerPass(new PluginResourceCompilerPass([$emptyPlugin, $filledPlugin]));
140+
$container->compile();
141+
142+
static::assertCount(2, $container->getDefinitions());
143+
144+
static::assertInstanceOf(ResourceSubscriber::class, $container->get('filled_plugin.internal.resource_subscriber'));
145+
}
110146
}

0 commit comments

Comments
 (0)