Skip to content

Commit 5029a16

Browse files
github-actions[bot]shopwareBot
andauthored
[create-pull-request] automated change (#2241)
Co-authored-by: shopwareBot <example@example.com>
1 parent 543b4c1 commit 5029a16

File tree

3 files changed

+6
-32
lines changed

3 files changed

+6
-32
lines changed

resources/guidelines/code/core/database-migrations.md renamed to resources/guidelines/code/core/database-migations.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
## Introduction
2-
32
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.
43
Therefore, it is important for every developer to understand the core principles of database migrations, also in the case of backward compatibility.
54

@@ -34,7 +33,7 @@ The migration consists of two separated steps: `update` and `updateDestructive`.
3433

3534
## Backward compatibility
3635

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.
3837
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.
3938

4039
* **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.
8584

8685
::: info
8786
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)
8988
:::
9089

9190
### 1. NEVER change an executed migration

resources/guidelines/code/core/extendability.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Regarding software extendability, different business cases and requirements must
1414
The requirements are divided into technical requirements and business requirements.
1515

1616
## Technical requirements
17-
1817
When talking about technical requirements, we talk about how we have to design our software for different extension use cases. These use cases include:
1918

2019
* Functional extensibility
@@ -31,7 +30,6 @@ When talking about technical requirements, we talk about how we have to design o
3130
* Ex: An external newsletter system should be connected
3231

3332
## Business requirements
34-
3533
When talking about business requirements, we talk about how the above technical requirements are used in different business cases. These business cases include:
3634
* Marketplace extensions
3735
* 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
4442
* Ex: Assets should be able to be loaded via CDN as there are several App Servers.
4543

4644
## Approaches
47-
4845
These business cases are realized with the following three conceptual approaches:
4946
- Project templates
5047
- 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
5855
- Plugin technology is designed to replace all areas in Shopware
5956

6057
## Patterns
61-
6258
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:
6359

6460
* Decoration
@@ -68,38 +64,32 @@ All the above requirements and approaches are based on different design patterns
6864
* Adapter
6965

7066
### Decoration
71-
7267
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.
7368

7469
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)
7570

7671
### Factory
77-
7872
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.
7973
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.
8074

8175
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.
8276

8377
### Visitor
84-
8578
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.
8679

8780
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.
8881

8982
### Mediator
90-
9183
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.
9284

9385
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;`.
9486

9587
#### 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**.
9889

9990
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.
10091

10192
### Adapter
102-
10393
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.
10494

10595
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.

resources/guidelines/code/core/feature-flags.md

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,19 @@ You can find the original version [here](https://github.com/shopware/shopware/bl
66
:::
77

88
## Introduction
9-
109
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)
1211

1312
### Activating the flag
14-
1513
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:
1614
```
1715
V6_5_0_0=1
1816
```
1917

2018
## Using flags in PHP
21-
2219
The feature flag can be used in PHP to make specific code parts only executable when the flag is active.
2320

2421
### Using flags in methods
25-
2622
When there is no option via the container you can use additional helper functions:
2723

2824
```php
@@ -101,15 +97,14 @@ class ApiController
10197
```
10298

10399
### Using flags in tests
104-
105100
You can flag a test by using the corresponding helper function. This can also be used in the `setUp()` method.
106101

107102
```php
108103
use Shopware\Core\Framework\Feature;
109104

110105
class ProductTest
111106
{
112-
public function testNewFeature()
107+
public function testNewFeature()
113108
{
114109
Feature::skipTestIfActive('v6.5.0.0', $this);
115110

@@ -118,12 +113,10 @@ class ProductTest
118113
}
119114
```
120115

121-
## Using flags in the Administration
122-
116+
## Using flags in the administration
123117
Also in the JavaScript code of the administration the flags can be used in various ways.
124118

125119
### Using flags for modules
126-
127120
You can also hide complete admin modules behind a flag:
128121

129122
```javascript
@@ -135,7 +128,6 @@ Module.register('sw-awesome', {
135128
```
136129

137130
### Using flags in JavaScript
138-
139131
To use a flag in a VueJS component you can inject the feature service and use it.
140132
```
141133
inject: ['feature'],
@@ -146,7 +138,6 @@ featureIsActive(flag) {
146138
```
147139

148140
### Using flags in templates
149-
150141
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:
151142

152143
```html
@@ -167,11 +158,9 @@ When you want to toggle config input fields in config.xml like [basicInformatati
167158
```
168159

169160
## Using flags in the storefront
170-
171161
In the Storefront it works nearly similar to the admin.
172162

173163
### Using flags in storefront JavaScript
174-
175164
```
176165
import Feature from 'src/helper/feature.helper';
177166
...
@@ -183,25 +172,21 @@ data() {
183172
```
184173

185174
### Using flags in storefront templates
186-
187175
```
188176
{% if feature('v6.5.0.0') %}
189177
<span>Feature is active</span>
190178
{% endif %}
191179
```
192180

193181
## Using flags in plugins
194-
195182
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.
196183

197184
### Major feature flag
198-
199185
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.
200186

201187
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`.
202188

203189
### Own plugin flags
204-
205190
<alert-box type="warning">This is internal only and we may break this behaviour at any time!</alert-box>
206191

207192
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

Comments
 (0)