Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 925066f

Browse files
authored
Merge pull request #5287 from magento/ds_sync-with-master
Sync develop with master
2 parents 24818b0 + 2378500 commit 925066f

36 files changed

+1327
-173
lines changed

_data/toc/javascript-developer-guide.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ pages:
4646
- label: Alert widget
4747
url: /javascript-dev-guide/widgets/widget_alert.html
4848

49+
- label: Breadcrumbs widget
50+
url: /javascript-dev-guide/widgets/widget-breadcrumbs.html
51+
4952
- label: Calendar widget
5053
url: /javascript-dev-guide/widgets/widget_calendar.html
5154

@@ -79,6 +82,9 @@ pages:
7982
- label: Modal widget
8083
url: /javascript-dev-guide/widgets/widget_modal.html
8184

85+
- label: Multiselect widget
86+
url: /javascript-dev-guide/widgets/widget-multiselect.html
87+
8288
- label: Navigation widget
8389
url: /javascript-dev-guide/widgets/widget_navigation.html
8490

@@ -97,6 +103,9 @@ pages:
97103
- label: RedirectUrl widget
98104
url: /javascript-dev-guide/widgets/widget_redirectUrl.html
99105

106+
- label: RowBuilder widget
107+
url: /javascript-dev-guide/widgets/widget-row-builder.html
108+
100109
- label: Tabs widget
101110
url: /javascript-dev-guide/widgets/widget_tabs.html
102111

_data/toc/php-developer-guide.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ pages:
256256
- label: Adapters
257257
url: /extension-dev-guide/adapters.html
258258

259+
- label: View models
260+
include_versions: ["2.2", "2.3"]
261+
url: /extension-dev-guide/view-models.html
262+
259263
- label: Variable Pool
260264
include_versions: ["2.3"]
261265
url: /extension-dev-guide/variable-pool/

_includes/config/split-deploy/example_save-shared-config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
```
3232

3333
{:.bs-callout .bs-callout-warning}
34-
Do _not_ submit changes to the `generated`, `pub/media`, or `pub/static` directories to source control. You'll generate those files on your build system. The production system likely has code, themes, and so on that aren't ready to use on production.
34+
Do _not_ submit changes to the `generated`, `pub/media`, or `pub/static` directories to source control. You'll generate those files on your build system. The development system likely has code, themes, and so on that are not ready for use on the production system.
3535
3636
1. Check in your changes to `app/etc/config.php` only to source control.
3737

_includes/mrg/note.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<div class="bs-callout bs-callout-info" markdown="1">
1+
{: .bs-callout-info }
22
This topic is generated automatically from the corresponding README in the Magento codebase.
33
If you want to contribute, refer to [Magento Code Contributions]({{ page.baseurl] }}/contributor-guide/contributing.html).
4-
</div>

_includes/reference/cli-template.md

Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -12,80 +12,82 @@ The initial list is auto generated using the `{{ tool }} list` command at the {{
1212

1313
{{ intro }}
1414

15+
## Reference
16+
17+
{: .bs-callout-info }
18+
This reference is generated from the Magento codebase. To add or update the content, you must update the source code for the corresponding CLI command in the [Magento 2 codebase](https://github.com/magento/magento2) repository and submit your changes for review. For contribution guidelines, see [Magento Code Contributions]({{ page.baseurl] }}/contributor-guide/contributing.html).
19+
1520
{% for command in commands %}
1621
{% assign arguments = command.definition.arguments %}
1722
{% assign options = command.definition.options %}
1823

19-
## `{{ command.name }}`
24+
### `{{ command.name }}`
2025

2126
{{ command.description }}
2227

2328
```bash
2429
{{ tool }} {{ command.usage }}
2530
```
2631

27-
{% unless arguments.size == 0 %}
32+
{% unless arguments.size == 0 %}
2833

29-
### Arguments
30-
{: .no_toc}
34+
#### Arguments
3135

32-
{% for argument in arguments %}
36+
{% for argument in arguments %}
3337
{% for item in argument %}
34-
{% if item.name %}
35-
36-
{% if item.default == empty %}
37-
{% endif %}
38-
39-
#### `{{ item.name }}`
40-
41-
- Description: {{ item.description }}
42-
{% unless item.default == nil %}
43-
{% if item.default == false or (item.default == empty and item.default != '') %}
44-
- Default: `{{ item.default | inspect }}`
45-
{% else %}
46-
- Default: `{{ item.default }}`
47-
{% endif %}
48-
{% endunless %}
49-
{% if item.is_required %}
50-
- Required
51-
{% endif %}
52-
{% if item.is_array %}
53-
- Array
54-
{% endif %}
55-
{% endif %}
56-
{% endfor %}
57-
{% endfor %}
58-
59-
### Options
60-
{: .no_toc}
38+
{% if item.name %}
39+
{% if item.default == empty %}
40+
{% endif %}
41+
42+
##### `{{ item.name }}`
43+
44+
- Description: {{ item.description }}
45+
{% unless item.default == nil %}
46+
{% if item.default == false or (item.default == empty and item.default != '') %}
47+
- Default: `{{ item.default | inspect }}`
48+
{% else %}
49+
- Default: `{{ item.default }}`
50+
{% endif %}
51+
{% endunless %}
52+
{% if item.is_required %}
53+
- Required
54+
{% endif %}
55+
{% if item.is_array %}
56+
- Array
57+
{% endif %}
58+
{% endif %}
59+
{% endfor %}
60+
{% endfor %}
61+
62+
#### Options
6163

6264
{% for option in options %}
6365
{% assign opt = option[1] %}
6466

65-
#### {{ option[0] }}
66-
67-
- Option: `{{ opt.name }}`
68-
{% if opt.shortcut contains '-' %}
69-
- Shortcut: `{{ opt.shortcut }}`
70-
{% endif %}
71-
- Description: {{ opt.description }}
72-
{% unless opt.default == nil %}
73-
{% if opt.default == false or (opt.default == empty and opt.default != '') %}
74-
- Default: `{{ opt.default | inspect }}`
75-
{% else %}
76-
- Default: `{{ opt.default }}`
77-
{% endif %}
78-
{% endunless %}
79-
{% if opt.is_value_required %}
80-
- Requires a value
81-
{% elsif opt.accept_value and opt.is_multiple %}
82-
- Accepts multiple values
83-
{% elsif opt.accept_value and opt.is_multiple == false %}
84-
- Accepts a value
85-
{% else %}
86-
- Does not accept a value
87-
{% endif %}
88-
{% endfor %}
67+
##### `{{ option[0] }}`
68+
69+
- Option: `{{ opt.name }}`
70+
{% if opt.shortcut contains '-' %}
71+
- Shortcut: `{{ opt.shortcut }}`
72+
{% endif %}
73+
- Description: {{ opt.description }}
74+
{% unless opt.default == nil %}
75+
{% if opt.default == false or (opt.default == empty and opt.default != '') %}
76+
- Default: `{{ opt.default | inspect }}`
77+
{% else %}
78+
- Default: `{{ opt.default }}`
79+
{% endif %}
80+
{% endunless %}
81+
{% if opt.is_value_required %}
82+
- Requires a value
83+
{% elsif opt.accept_value and opt.is_multiple %}
84+
- Accepts multiple values
85+
{% elsif opt.accept_value and opt.is_multiple == false %}
86+
- Accepts a value
87+
{% else %}
88+
- Does not accept a value
89+
{% endif %}
90+
{% endfor %}
8991

9092
{% endunless %}
9193
{% endfor %}
28.9 KB
Loading
Loading
Loading
15.7 KB
Loading
Loading
Loading
Loading

guides/v2.2/cloud/project/project-upgrade.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,13 @@ For an upgrade, you delete the `config.php` file. Once this file is added to you
157157

158158
## Verify and upgrade your extensions {#extensions}
159159

160-
If you need to upgrade any third-party extensions and modules that support version 2.2, we recommend working in a new Integration branch with your extensions disabled. Review your third-party extension and module pages in Marketplace or other company sites to verify support for {{site.data.var.ee}} and {{site.data.var.ece}} version 2.2.
160+
{%
161+
include note.html
162+
type='info'
163+
content='Review your third-party extension and module pages in Marketplace or other company sites to verify support for Magento Commerce and Magento Commerce Cloud version 2.2.
164+
165+
If you need to upgrade any third-party extensions and modules that support version 2.2, we recommend working in a new Integration branch with your extensions disabled.'
166+
%}
161167

162168
1. Create a new branch on your local workstation.
163169

guides/v2.2/extension-dev-guide/build/di-xml-file.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,49 @@ See [sensitive and environment settings]({{ page.baseurl }}/extension-dev-guide/
353353
* [Sensitive and system-specific configuration paths reference]({{ page.baseurl }}/config-guide/prod/config-reference-sens.html)
354354
* [Magento Enterprise B2B Extension configuration paths reference]({{ page.baseurl }}/config-guide/prod/config-reference-b2b.html)
355355

356+
## Get dependency injection configuration information for a class
357+
358+
Use the [dev:di:info]({{ page.baseurl }}/reference/cli/magento.html#devdiinfo) command to retrieve information about dependency injection configuration for a class. The following example retrieves the dependency injection configuration information for the `Magento\Quote\Model\Quote\Item\ToOrderItem` class:
359+
360+
```bash
361+
bin/magento dev:di:info "Magento\Quote\Model\Quote\Item\ToOrderItem"
362+
```
363+
364+
```terminal
365+
DI configuration for the class Magento\Quote\Model\Quote\Item\ToOrderItem in the GLOBAL area
366+
367+
Preference: Magento\Quote\Model\Quote\Item\ToOrderItem
368+
369+
Constructor Parameters:
370+
+-------------------+--------------------------------------------------+------------------+
371+
| Name | Requested Type | Configured Value |
372+
+-------------------+--------------------------------------------------+------------------+
373+
| orderItemFactory | Magento\Sales\Api\Data\OrderItemInterfaceFactory | |
374+
| objectCopyService | Magento\Framework\DataObject\Copy | |
375+
| dataObjectHelper | Magento\Framework\Api\DataObjectHelper | |
376+
+-------------------+--------------------------------------------------+------------------+
377+
378+
379+
Plugins:
380+
+-----------------------------------------------------+---------+--------+
381+
| Plugin | Method | Type |
382+
+-----------------------------------------------------+---------+--------+
383+
| Magento\Catalog\Model\Plugin\QuoteItemProductOption | convert | before |
384+
| Magento\GiftMessage\Model\Plugin\QuoteItem | convert | after |
385+
| Magento\Bundle\Model\Plugin\QuoteItem | convert | after |
386+
+-----------------------------------------------------+---------+--------+
387+
388+
389+
Plugins for the Preference:
390+
+-----------------------------------------------------+---------+--------+
391+
| Plugin | Method | Type |
392+
+-----------------------------------------------------+---------+--------+
393+
| Magento\Catalog\Model\Plugin\QuoteItemProductOption | convert | before |
394+
| Magento\GiftMessage\Model\Plugin\QuoteItem | convert | after |
395+
| Magento\Bundle\Model\Plugin\QuoteItem | convert | after |
396+
+-----------------------------------------------------+---------+--------+
397+
```
398+
356399
## Related topics
357400

358401
* [ObjectManager]({{ page.baseurl }}/extension-dev-guide/object-manager.html)

guides/v2.2/extension-dev-guide/module-development.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ Magento 2 is flexible and as a result has varied functionality, so developing a
2121
* [Routing]({{ page.baseurl }}/extension-dev-guide/routing.html)
2222
* [Indexing]({{ page.baseurl }}/extension-dev-guide/indexing.html)
2323
* [Configure a service as a web API]({{ page.baseurl }}/extension-dev-guide/service-contracts/service-to-web-service.html#configure-webapi)
24+
* [ViewModels]({{ page.baseurl }}/extension-dev-guide/view-models.html)

guides/v2.2/extension-dev-guide/plugins.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,44 @@ By applying code before, after, or around a public method, a plugin extends or m
5757

5858
The first argument for the before, after, and around methods is an object that provides access to all public methods of the observed method's class.
5959

60+
### Plugin method naming convention
61+
62+
It is a Magento best practice to capitalize the first letter of the class method name for which you want to create a plugin before adding `before`, `around` or `after` prefixes to it.
63+
64+
For example, to create a plugin for the `setName` method of some class:
65+
66+
```php
67+
...
68+
public function setName($name)
69+
{
70+
...
71+
}
72+
...
73+
```
74+
75+
In the plugin class, the `setName` method may have one of the following names:
76+
- `beforeSetName`
77+
- `aroundSetName`
78+
- `afterSetName`
79+
80+
If the first letter in the name of the class method name for which you want to create a plugin is the `underscore` character, then you do not need to capitalize it in the plugin class.
81+
82+
For example, to create a plugin for the `_construct` method of some class:
83+
84+
```php
85+
...
86+
public function _construct()
87+
{
88+
...
89+
}
90+
...
91+
```
92+
93+
Use the following method names for the `_construct` method in the plugin class:
94+
- `before_construct`
95+
- `around_construct`
96+
- `after_construct`
97+
6098
#### Before methods
6199

62100
Magento runs all before methods ahead of the call to an observed method. These methods must have the same name as the observed method with 'before' as the prefix.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: View models
3+
contributor_name: Space 48
4+
contributor_link: https://www.space48.com/
5+
group: php-developer-guide
6+
---
7+
8+
A view model is an abstraction of the view exposing public properties and commands. It allows developers to offload features and business logic from block classes into separate classes that are easier to maintain, test, and reuse.
9+
10+
## When to use view models
11+
12+
Use this approach anytime you need to inject functionality into template files and your code does not need to be backwards compatible with Magento 2.1.
13+
14+
{: .bs-callout-info }
15+
View models are available in Magento 2.2 onwards. If your code must be compatible with older versions of Magento, consider adding your logic to blocks. For more information about backward compatibility, see [Backward compatibility]({{ page.baseurl }}/contributor-guide/backward-compatible-development/).
16+
17+
## How to write view models
18+
19+
The following example shows how to add functionality to a core template with custom logic using a view model in the `cart/item/default.phtml` template, which is located in the `Magento/Checkout/view/frontend/layout/checkout_cart_item_renderers.xml` file:
20+
21+
```xml
22+
<?xml version="1.0"?>
23+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
24+
<body>
25+
<referenceBlock name="checkout.cart.item.renderers.default">
26+
<arguments>
27+
<argument name="viewModel" xsi:type="object">Vendor\CustomModule\ViewModel\MyClass</argument>
28+
</arguments>
29+
</referenceBlock>
30+
</body>
31+
```
32+
33+
You must implement the right interface in your `viewModel` class (for example `ArgumentInterface`):
34+
35+
```php
36+
namespace Vendor\CustomModule\ViewModel;
37+
38+
class MyClass implements \Magento\Framework\View\Element\Block\ArgumentInterface
39+
{
40+
public function getTitle()
41+
{
42+
return 'Hello World'
43+
{
44+
}
45+
```
46+
47+
Finally, in the `cart/item/default.phtml` template, you can access the public methods of your view model:
48+
49+
```html
50+
<?php
51+
52+
/** @var $viewModel \Vendor\CustomModule\ViewModel\MyClass */
53+
54+
$viewModel = $block->getViewModel();
55+
56+
?>
57+
<h1><?= $block->escapeHtml($viewModel->getTitle()); ?></h1>
58+
59+
```
60+
61+
## Examples of View models in Magento
62+
63+
- [Magento_Catalog]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml#L34){:target="_blank"}
64+
This `viewModel` is used to inject breadcrumb JSON with HTML-escaped names into the template file.

0 commit comments

Comments
 (0)