Skip to content

Commit 25378a5

Browse files
committed
NEXT-21200 - Allow plugin composer requirements
1 parent ecfd0c7 commit 25378a5

File tree

7 files changed

+39
-88
lines changed

7 files changed

+39
-88
lines changed

changelog/_unreleased/2020-12-10-new-option-for-plugins.md

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: New option for plugins using Composer 2
33
issue: NEXT-1797
4-
flag: FEATURE_NEXT_1797
54
author: Michael Telgmann
65
author_github: @mitelg
76
---
@@ -11,19 +10,8 @@ author_github: @mitelg
1110
* Added new method `executeComposerCommands` to `Shopware\Core\Framework\Plugin` to enable composer commands during plugin install/update/uninstall
1211
___
1312
# Upgrade Information
13+
## New `executeComposerCommands` option for plugins
1414

15-
## Update to Composer 2
16-
Make sure that your `composer.json` file in your plugin matches the requirements of [Composer](https://getcomposer.org/doc/04-schema.md).
17-
Especially the `name` property should be checked.
18-
19-
## Composer runtime API
20-
With Shopware 6.4 we are now requiring the `composer-runtime-api` with version 2.0.
21-
These means that Shopware is now only installable with Composer 2.
22-
Installation with Composer 1 is no longer possible and supported.
23-
24-
## New option for plugins
25-
Updating the core dependency `composer/composer` to version 2 enables the possibility to execute composer commands
26-
during the installation, update and uninstallation of a plugin.
2715
If your plugin provides 3rd party dependencies, override the `executeComposerCommands` method in your plugin base class
2816
and return true.
2917
Now on plugin installation and update of the plugin a `composer require` of your plugin will also be executed,

composer.json

+18-9
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,8 @@
6363
"doctrine/annotations": "^1.14",
6464
"doctrine/dbal": "^3.5",
6565
"doctrine/inflector": "^2.0",
66-
"tecnickcom/tcpdf": "6.6.1",
67-
"setasign/fpdi": "2.3.6",
68-
"opensearch-project/opensearch-php": "~2.0",
69-
"ezyang/htmlpurifier": "~4.16",
7066
"erusev/parsedown-extra": "0.8.1",
67+
"ezyang/htmlpurifier": "~4.16",
7168
"guzzlehttp/guzzle": "~7.4.5",
7269
"guzzlehttp/psr7": "^2.4",
7370
"lcobucci/jwt": "^4.2",
@@ -78,6 +75,7 @@
7875
"league/oauth2-server": "~8.3.6",
7976
"meyfa/php-svg": "~0.13.0",
8077
"nyholm/psr7": "^1.5",
78+
"opensearch-project/opensearch-php": "~2.0",
8179
"padaliyajay/php-autoprefixer": "1.4",
8280
"psr/cache": "~3.0.0",
8381
"psr/event-dispatcher": "~1.0.0",
@@ -86,9 +84,11 @@
8684
"psr/log": "~3.0.0",
8785
"scssphp/scssphp": "v1.11.0",
8886
"sensio/framework-extra-bundle": "~6.2.1",
87+
"setasign/fpdi": "2.3.6",
8988
"shopware/conflicts": "*",
9089
"shopwarelabs/dompdf": "1.0.3",
9190
"shyim/opensearch-php-dsl": "~1.0.1",
91+
"squirrelphp/twig-php-syntax": "~1.7.0",
9292
"symfony/asset": "~6.2.0",
9393
"symfony/cache": "~6.2.0",
9494
"symfony/cache-contracts": "~3.1.0",
@@ -97,8 +97,8 @@
9797
"symfony/debug-bundle": "~6.2.0",
9898
"symfony/dependency-injection": "~6.2.0",
9999
"symfony/deprecation-contracts": "~3.1.0",
100-
"symfony/dotenv": "~6.2.0",
101100
"symfony/doctrine-messenger": "~6.2.0",
101+
"symfony/dotenv": "~6.2.0",
102102
"symfony/error-handler": "~6.2.0",
103103
"symfony/event-dispatcher": "~6.2.0",
104104
"symfony/event-dispatcher-contracts": "~3.1.0",
@@ -110,18 +110,18 @@
110110
"symfony/lock": "~6.2.0",
111111
"symfony/mailer": "~6.2.0",
112112
"symfony/messenger": "~6.2.0",
113-
"symfony/proxy-manager-bridge": "~6.2.0",
114113
"symfony/mime": "~6.2.0",
115114
"symfony/monolog-bridge": "~6.2.0",
116115
"symfony/monolog-bundle": "~3.8.0",
117116
"symfony/options-resolver": "~6.2.0",
118117
"symfony/process": "~6.2.0",
119118
"symfony/property-access": "~6.2.0",
120119
"symfony/property-info": "~6.2.0",
120+
"symfony/proxy-manager-bridge": "~6.2.0",
121121
"symfony/psr-http-message-bridge": "~2.1.3",
122122
"symfony/rate-limiter": "~6.2.0",
123-
"symfony/runtime": "~6.2.0",
124123
"symfony/routing": "~6.2.0",
124+
"symfony/runtime": "~6.2.0",
125125
"symfony/security-core": "~6.2.0",
126126
"symfony/security-csrf": "~6.2.0",
127127
"symfony/serializer": "~6.2.0",
@@ -134,11 +134,11 @@
134134
"symfony/validator": "~6.2.0",
135135
"symfony/var-exporter": "~6.2.0",
136136
"symfony/yaml": "~6.2.0",
137+
"tecnickcom/tcpdf": "6.6.1",
137138
"twig/intl-extra": "^3.4",
138139
"twig/string-extra": "^3.4",
139140
"twig/twig": "~3.4.3",
140-
"zircote/swagger-php": "~4.5.1",
141-
"squirrelphp/twig-php-syntax": "~1.7.0"
141+
"zircote/swagger-php": "~4.5.1"
142142
},
143143
"require-dev": {
144144
"ext-tokenizer": "*",
@@ -173,6 +173,15 @@
173173
"symfony/var-dumper": "~6.1.0",
174174
"symfony/web-profiler-bundle": "~6.1.0"
175175
},
176+
"repositories": [
177+
{
178+
"type": "path",
179+
"url": "custom/plugins/*",
180+
"options": {
181+
"symlink": true
182+
}
183+
}
184+
],
176185
"conflict": {
177186
"monolog/monolog": "^1.0",
178187
"enqueue/enqueue": "<0.10.16"

custom/plugins/.gitkeep

Whitespace-only changes.

src/Core/Framework/DataAbstractionLayer/Write/WriteParameterBag.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
use Shopware\Core\Framework\Uuid\Uuid;
1010

1111
/**
12-
* @inernal
13-
*
1412
* @package core
13+
*
14+
* @internal
1515
*/
1616
class WriteParameterBag
1717
{

src/Core/Framework/Plugin/Composer/CommandExecutor.php

+4-12
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,15 @@
1313
*/
1414
class CommandExecutor
1515
{
16-
/**
17-
* @var Application
18-
*/
19-
private $application;
20-
21-
/**
22-
* @var string
23-
*/
24-
private $projectDir;
16+
private Application $application;
2517

2618
/**
2719
* @internal
2820
*/
29-
public function __construct(string $projectDir)
21+
public function __construct(private string $projectDir)
3022
{
3123
$this->application = new Application();
3224
$this->application->setAutoExit(false);
33-
34-
$this->projectDir = $projectDir;
3525
}
3626

3727
public function require(string $pluginComposerName, string $pluginName): void
@@ -44,6 +34,7 @@ public function require(string $pluginComposerName, string $pluginName): void
4434
'--working-dir' => $this->projectDir,
4535
'--no-interaction' => null,
4636
'--update-with-dependencies' => null,
37+
'--no-scripts' => null,
4738
]
4839
);
4940

@@ -65,6 +56,7 @@ public function remove(string $pluginComposerName, string $pluginName): void
6556
'packages' => [$pluginComposerName],
6657
'--working-dir' => $this->projectDir,
6758
'--no-interaction' => null,
59+
'--no-scripts' => null,
6860
]
6961
);
7062

src/Core/Framework/Plugin/PluginLifecycleService.php

+14-48
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
1111
use Shopware\Core\Framework\DataAbstractionLayer\Search\EntitySearchResult;
1212
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter;
13-
use Shopware\Core\Framework\Feature;
1413
use Shopware\Core\Framework\Migration\MigrationCollection;
1514
use Shopware\Core\Framework\Migration\MigrationCollectionLoader;
1615
use Shopware\Core\Framework\Migration\MigrationSource;
@@ -57,52 +56,19 @@ class PluginLifecycleService
5756
{
5857
public const STATE_SKIP_ASSET_BUILDING = 'skip-asset-building';
5958

60-
private EntityRepository $pluginRepo;
61-
62-
private EventDispatcherInterface $eventDispatcher;
63-
64-
private KernelPluginCollection $pluginCollection;
65-
66-
private ContainerInterface $container;
67-
68-
private MigrationCollectionLoader $migrationLoader;
69-
70-
private AssetService $assetInstaller;
71-
72-
private CommandExecutor $executor;
73-
74-
private RequirementsValidator $requirementValidator;
75-
76-
private string $shopwareVersion;
77-
78-
private CacheItemPoolInterface $restartSignalCachePool;
79-
80-
private SystemConfigService $systemConfigService;
81-
8259
public function __construct(
83-
EntityRepository $pluginRepo,
84-
EventDispatcherInterface $eventDispatcher,
85-
KernelPluginCollection $pluginCollection,
86-
ContainerInterface $container,
87-
MigrationCollectionLoader $migrationLoader,
88-
AssetService $assetInstaller,
89-
CommandExecutor $executor,
90-
RequirementsValidator $requirementValidator,
91-
CacheItemPoolInterface $restartSignalCachePool,
92-
string $shopwareVersion,
93-
SystemConfigService $systemConfigService
60+
private EntityRepository $pluginRepo,
61+
private EventDispatcherInterface $eventDispatcher,
62+
private KernelPluginCollection $pluginCollection,
63+
private ContainerInterface $container,
64+
private MigrationCollectionLoader $migrationLoader,
65+
private AssetService $assetInstaller,
66+
private CommandExecutor $executor,
67+
private RequirementsValidator $requirementValidator,
68+
private CacheItemPoolInterface $restartSignalCachePool,
69+
private string $shopwareVersion,
70+
private SystemConfigService $systemConfigService
9471
) {
95-
$this->pluginRepo = $pluginRepo;
96-
$this->eventDispatcher = $eventDispatcher;
97-
$this->pluginCollection = $pluginCollection;
98-
$this->container = $container;
99-
$this->migrationLoader = $migrationLoader;
100-
$this->assetInstaller = $assetInstaller;
101-
$this->executor = $executor;
102-
$this->requirementValidator = $requirementValidator;
103-
$this->systemConfigService = $systemConfigService;
104-
$this->shopwareVersion = $shopwareVersion;
105-
$this->restartSignalCachePool = $restartSignalCachePool;
10672
}
10773

10874
/**
@@ -125,7 +91,7 @@ public function installPlugin(PluginEntity $plugin, Context $shopwareContext): I
12591
return $installContext;
12692
}
12793

128-
if (Feature::isActive('FEATURE_NEXT_1797') && $pluginBaseClass->executeComposerCommands()) {
94+
if ($pluginBaseClass->executeComposerCommands()) {
12995
$pluginComposerName = $plugin->getComposerName();
13096
if ($pluginComposerName === null) {
13197
throw new PluginComposerJsonInvalidException(
@@ -193,7 +159,7 @@ public function uninstallPlugin(
193159
$pluginBaseClassString = $plugin->getBaseClass();
194160
$pluginBaseClass = $this->getPluginBaseClass($pluginBaseClassString);
195161

196-
if (Feature::isActive('FEATURE_NEXT_1797') && $pluginBaseClass->executeComposerCommands()) {
162+
if ($pluginBaseClass->executeComposerCommands()) {
197163
$pluginComposerName = $plugin->getComposerName();
198164
if ($pluginComposerName === null) {
199165
throw new PluginComposerJsonInvalidException(
@@ -267,7 +233,7 @@ public function updatePlugin(PluginEntity $plugin, Context $shopwareContext): Up
267233
$plugin->getUpgradeVersion() ?? $plugin->getVersion()
268234
);
269235

270-
if (Feature::isActive('FEATURE_NEXT_1797') && $pluginBaseClass->executeComposerCommands()) {
236+
if ($pluginBaseClass->executeComposerCommands()) {
271237
$pluginComposerName = $plugin->getComposerName();
272238
if ($pluginComposerName === null) {
273239
throw new PluginComposerJsonInvalidException(

src/Core/Framework/Resources/config/packages/feature.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ shopware:
77
- name: v6.6.0.0
88
default: false
99
major: true
10-
- name: FEATURE_NEXT_1797
11-
default: false
12-
major: true
13-
description: "composer require for plugins"
1410
- name: FEATURE_NEXT_19501
1511
default: false
1612
major: false

0 commit comments

Comments
 (0)