You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: resources/guidelines/code/core/database-migations.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,4 @@
1
1
## Introduction
2
-
3
2
Changing the database structure of Shopware is an important and sensitive topic, because it can effect the installation of customers and their data in many ways.
4
3
Therefore, it is important for every developer to understand the core principles of database migrations, also in the case of backward compatibility.
5
4
@@ -34,7 +33,7 @@ The migration consists of two separated steps: `update` and `updateDestructive`.
34
33
35
34
## Backward compatibility
36
35
37
-
As every other change, also your database changes should always be [backward compatible](../backward-compatibility.md) for minor and patch releases and support blue-green deployment.
36
+
As every other change, also your database changes should always be [backward compatible](/docs/resources/guidelines/code/backward-compatibility.html) for minor and patch releases and support blue-green deployment.
38
37
A common technique is the [expand and contract](https://www.tim-wellhausen.de/papers/ExpandAndContract/ExpandAndContract.html) pattern, which will help you to implement your changes in a backward compatible way.
39
38
40
39
***Expand**: Instead of renaming an existing column, create a new column with the updated name. (non-destructive)
@@ -85,7 +84,7 @@ Migrations are executed in following order.
85
84
86
85
::: info
87
86
This document represents core guidelines and has been mirrored from the core in our Shopware 6 repository.
88
-
You can find the original version [here](https://github.com/shopware/shopware/blob/trunk/coding-guidelines/core/database-migrations.md)
87
+
You can find the original version [here](https://github.com/shopware/shopware/blob/trunk/coding-guidelines/core/database-migations.md)
Copy file name to clipboardExpand all lines: resources/guidelines/code/core/extendability.md
+1-11Lines changed: 1 addition & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,6 @@ Regarding software extendability, different business cases and requirements must
14
14
The requirements are divided into technical requirements and business requirements.
15
15
16
16
## Technical requirements
17
-
18
17
When talking about technical requirements, we talk about how we have to design our software for different extension use cases. These use cases include:
19
18
20
19
* Functional extensibility
@@ -31,7 +30,6 @@ When talking about technical requirements, we talk about how we have to design o
31
30
* Ex: An external newsletter system should be connected
32
31
33
32
## Business requirements
34
-
35
33
When talking about business requirements, we talk about how the above technical requirements are used in different business cases. These business cases include:
36
34
* Marketplace extensions
37
35
* We should build the software so everyone can easily provide new features in certain areas.
@@ -44,7 +42,6 @@ When talking about business requirements, we talk about how the above technical
44
42
* Ex: Assets should be able to be loaded via CDN as there are several App Servers.
45
43
46
44
## Approaches
47
-
48
45
These business cases are realized with the following three conceptual approaches:
49
46
- Project templates
50
47
- Large customers have their deployments in which they deploy a fork of our production template.
@@ -58,7 +55,6 @@ These business cases are realized with the following three conceptual approaches
58
55
- Plugin technology is designed to replace all areas in Shopware
59
56
60
57
## Patterns
61
-
62
58
All the above requirements and approaches are based on different design patterns within our architecture. To realize the extensibility, we use the following patterns, which allow the third-party developer to extend our software:
63
59
64
60
* Decoration
@@ -68,38 +64,32 @@ All the above requirements and approaches are based on different design patterns
68
64
* Adapter
69
65
70
66
### Decoration
71
-
72
67
With the Decoration pattern, we make it possible to replace or extend certain areas in Shopware completely. We often use this pattern for our Store API routes to provide more functionality in the Store API. Another use case is the **functional replacement market** case, where we can completely replace features with other technologies or external libraries.
73
68
74
69
An example Store API route is the CategoryRoute. For this route, there is an [Abstract class](https://github.com/shopware/shopware/blob/v6.4.12.0/src/Core/Content/Category/SalesChannel/AbstractCategoryRoute.php) to which we type behind a [Concrete implementation](https://github.com/shopware/shopware/blob/v6.4.12.0/src/Core/Content/Category/SalesChannel/CategoryRoute.php) and a [Cache decorator](https://github.com/shopware/shopware/blob/v6.4.12.0/src/Core/Content/Category/SalesChannel/CachedCategoryRoute.php)
75
70
76
71
### Factory
77
-
78
72
The factory pattern is often used when we have to interpret user input and validate or enrich this input before it is passed to the application.
79
73
One use case for the factory pattern is the **Functional extensibility**, to allow third-party developers to add new factories, which allow other user input.
80
74
81
75
A good example is the [line item factory registry](https://github.com/shopware/shopware/blob/v6.4.12.0/src/Core/Checkout/Cart/LineItemFactoryRegistry.php). This registry is used when an item is to be added to the shopping cart via store-API. [The corresponding handler](https://github.com/shopware/shopware/blob/v6.4.12.0/src/Core/Checkout/Cart/LineItemFactoryHandler/ProductLineItemFactory.php) is responsible for the instantiation of the line item and enriches it with necessary data.
82
76
83
77
### Visitor
84
-
85
78
The visitor pattern is often used when we process some objects within our application. This pattern is often used to fit the **Functional extensibility** and **Functional modifiability** requirements. In theory, after or before the core visitors are executed, the third party visitors are executed, and they can visit the objects and manipulate or extend the processed data beforehand or afterward to manipulate the result.
86
79
87
80
A good example of the visitor pattern is the [cart processor](https://github.com/shopware/shopware/blob/v6.4.12.0/src/Core/Checkout/Cart/Processor.php). The processor calls all line item processors, like the [product cart process](https://github.com/shopware/shopware/blob/v6.4.12.0/src/Core/Content/Product/Cart/ProductCartProcessor.php), to modify the provided cart object and transport the line items from the previous cart to the calculated.
88
81
89
82
### Mediator
90
-
91
83
We often use this pattern to realize **functional extensibility** and **functional modifiability** to manipulate data or extend it with additional data sources. The best-known example of this pattern in our application is Events. We use events to create different entry points for developers to trigger specific processes.
92
84
93
85
The best-known example is the [`checkout.order.placed`](https://github.com/shopware/shopware/blob/v6.4.12.0/src/Core/Checkout/Cart/Event/CheckoutOrderPlacedEvent.php) event. This event is [dispatched](https://github.com/shopware/shopware/blob/v6.4.12.0/src/Core/Checkout/Cart/SalesChannel/CartOrderRoute.php#L151) as soon as an order is created in the system. However, over time, it has been shown that it is best practice not to pass objects or entities around in events, but only a corresponding primary key so that the connected listeners can determine the data for themselves. Furthermore, possible asynchronous processing of the underlying processes is easier to realize this way. An optimized variant of this event would not contain the `private OrderEntity $order;` but only the primary key for the order `private string $orderId;`.
94
86
95
87
#### Hooks
96
-
97
-
Hooks are another good example of the observer pattern. Hooks are entry points for apps in which the so-called [**App scripts**](../../../../guides/plugins/apps/app-scripts/index.md) is enabled. Since apps do not have the permission to execute code on the server directly, hooks are a way to execute more complex business logic within the request without having to address the own app server via HTTP. Hooks are the equivalent of **events**.
88
+
Hooks are another good example of the observer pattern. Hooks are entry points for apps in which the so-called [**App scripts**](/docs/guides/plugins/apps/app-scripts/) is enabled. Since apps do not have the permission to execute code on the server directly, hooks are a way to execute more complex business logic within the request without having to address the own app server via HTTP. Hooks are the equivalent of **events**.
98
89
99
90
One of the best-known hooks is the [`product page loaded hook`](https://github.com/shopware/shopware/blob/v6.4.12.0/src/Storefront/Page/Product/ProductPageLoadedHook.php). This hook allows apps to load additional data on the product detail page. The hook is instantiated and dispatched [at controller level](https://github.com/shopware/shopware/blob/v6.4.12.0/src/Storefront/Controller/ProductController.php#L100). Each app script, which is registered to the hook, is executed.
100
91
101
92
### Adapter
102
-
103
93
The adapter pattern is perfectly designed for **Functional exchange market**. We often realize this by allowing the user to do some configuration and select a corresponding adapter. These adapters are usually registered inside a registry, and third-party developers can easily add new adapters via events or via tagged services.
104
94
105
95
A good example is the captcha implementation. The store owner can configure a [captcha type](https://docs.shopware.com/en/shopware-en/settings/basic-information#captcha), and we then use the [corresponding adapter](https://github.com/shopware/shopware/blob/v6.4.12.0/src/Storefront/Framework/Captcha/HoneypotCaptcha.php#L11) in the code for the configured captcha.
Copy file name to clipboardExpand all lines: resources/guidelines/code/core/feature-flags.md
+3-18Lines changed: 3 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,23 +6,19 @@ You can find the original version [here](https://github.com/shopware/shopware/bl
6
6
:::
7
7
8
8
## Introduction
9
-
10
9
Feature flags enable the developer to create new code which is hidden behind the flag and merge it into the trunk branch, even when the code is not finalized.
11
-
We use this functionality to merge breaks into the trunk early, without them already being switched active. To learn more about breaking changes and backward compatibility take a look to our [Backward Compatibility Guide](../backward-compatibility.md).
10
+
We use this functionality to merge breaks into the trunk early, without them already being switched active. To learn more about breaking changes and backward compability take a look to our [Backward Compatibility Guide](/docs/resources/guidelines/code/backward-compatibility.html)
12
11
13
12
### Activating the flag
14
-
15
13
To switch flags on and off you can use the ***.env*** to configure each feature flag. Using dots inside an env variable are not allowed, so we use underscore instead:
16
14
```
17
15
V6_5_0_0=1
18
16
```
19
17
20
18
## Using flags in PHP
21
-
22
19
The feature flag can be used in PHP to make specific code parts only executable when the flag is active.
23
20
24
21
### Using flags in methods
25
-
26
22
When there is no option via the container you can use additional helper functions:
27
23
28
24
```php
@@ -101,15 +97,14 @@ class ApiController
101
97
```
102
98
103
99
### Using flags in tests
104
-
105
100
You can flag a test by using the corresponding helper function. This can also be used in the `setUp()` method.
106
101
107
102
```php
108
103
use Shopware\Core\Framework\Feature;
109
104
110
105
class ProductTest
111
106
{
112
-
public function testNewFeature()
107
+
public function testNewFeature()
113
108
{
114
109
Feature::skipTestIfActive('v6.5.0.0', $this);
115
110
@@ -118,12 +113,10 @@ class ProductTest
118
113
}
119
114
```
120
115
121
-
## Using flags in the Administration
122
-
116
+
## Using flags in the administration
123
117
Also in the JavaScript code of the administration the flags can be used in various ways.
124
118
125
119
### Using flags for modules
126
-
127
120
You can also hide complete admin modules behind a flag:
To use a flag in a VueJS component you can inject the feature service and use it.
140
132
```
141
133
inject: ['feature'],
@@ -146,7 +138,6 @@ featureIsActive(flag) {
146
138
```
147
139
148
140
### Using flags in templates
149
-
150
141
When you want to toggle different parts of the template you can use the flag in a VueJs condition if you injected the service in the module:
151
142
152
143
```html
@@ -167,11 +158,9 @@ When you want to toggle config input fields in config.xml like [basicInformatati
167
158
```
168
159
169
160
## Using flags in the storefront
170
-
171
161
In the Storefront it works nearly similar to the admin.
172
162
173
163
### Using flags in storefront JavaScript
174
-
175
164
```
176
165
import Feature from 'src/helper/feature.helper';
177
166
...
@@ -183,25 +172,21 @@ data() {
183
172
```
184
173
185
174
### Using flags in storefront templates
186
-
187
175
```
188
176
{% if feature('v6.5.0.0') %}
189
177
<span>Feature is active</span>
190
178
{% endif %}
191
179
```
192
180
193
181
## Using flags in plugins
194
-
195
182
Feature flags can also be used in plugins. Among other things, by adding your own flags, but also the use of the major feature flag is an intended use case.
196
183
197
184
### Major feature flag
198
-
199
185
As mentioned before, we use the major feature flags (`v6.5.0.0`, `v6.6.0.0`) to signal breaks within the code ahead of time. This is an incredible help in the preparation of the next major release, as otherwise all breaks would have to be made within a short period of time.
200
186
201
187
This procedure can also be applied to plugins, which also use this flag and internally query it to either prepare the plugin for the next major or to support multiple Shopware major versions with one plugin version. Since each major feature flag remains after the corresponding release, they can be used as an alternative version switch to the php equivalent `version_compare`.
202
188
203
189
### Own plugin flags
204
-
205
190
<alert-boxtype="warning">This is internal only and we may break this behaviour at any time!</alert-box>
206
191
207
192
When you need to implement a feature flag for a plugin you can't edit the feature.yaml or provide an override for it,
0 commit comments