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
{{ message }}
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: guides/v2.2/extension-dev-guide/api-concepts.md
+13-12Lines changed: 13 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -8,24 +8,25 @@ menu_order: 3
8
8
9
9
## What is a public interface? {#public-interface}
10
10
11
-
<p>A <i>public interface</i> is a set of code that third-party developers can call, implement, or build as a [plug-in](https://glossary.magento.com/plug-in). Magento guarantees that this code will not change in subsequent releases without a major version change.</p>
12
-
<p>Public interfaces for a [module](https://glossary.magento.com/module) are marked with <code>@api</code> annotation.</p>
11
+
A _public interface_ is a set of code that third-party developers can call, implement, or build as a [plug-in](https://glossary.magento.com/plug-in). Magento guarantees that this code will not change in subsequent releases without a major version change.
12
+
13
+
Public interfaces for a [module](https://glossary.magento.com/module) are marked with `@api` annotation.
13
14
14
15
{: .bs-callout-info }
15
16
Third-party developers should use only these interfaces, that is, interfaces with the `@api` annotation. You can use other interfaces but those may be modified or removed in subsequent Magento releases. For more information, see [Backward compatibility]({{ page.baseurl }}/contributor-guide/backward-compatible-development/).
16
17
17
18
## What is an API? {#api-definition}
18
19
19
-
<p>An application programming interface (API) is a set of interfaces and their implementations that a module provides to other modules.</p>
20
+
An application programming interface (API) is a set of interfaces and their implementations that a module provides to other modules.
20
21
21
22
### API types {#api-types}
22
23
23
-
<p>The following items are considered types of APIs:</p>
<p>Directory structure and configuration file structure are types of APIs because [extension](https://glossary.magento.com/extension) developers use them. Developers write configurations, and place their [static files](https://glossary.magento.com/static-files) in specified folders; so if the configuration file structure or directory structure changes in subsequent releases, modules and extensions may break.</p>
Directory structure and configuration file structure are types of APIs because [extension](https://glossary.magento.com/extension) developers use them. Developers write configurations, and place their [static files](https://glossary.magento.com/static-files) in specified folders; so if the configuration file structure or directory structure changes in subsequent releases, modules and extensions may break.
Copy file name to clipboardExpand all lines: guides/v2.2/extension-dev-guide/service-contracts/design-patterns.md
+43-38Lines changed: 43 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -6,59 +6,65 @@ menu_title: Service contract design patterns
6
6
menu_order: 4
7
7
---
8
8
9
-
<p>In the programming community, a <i>design pattern</i> is a recommended way of writing code that includes when to use, or not use, the pattern. Think of a [design pattern](https://glossary.magento.com/design-pattern) as a best practice with conditions.</p>
10
-
<p>Design patterns for service contracts tell you which types of interfaces to define, and how and where to define and implement those interfaces.</p>
9
+
In the programming community, a _design pattern_ is a recommended way of writing code that includes when to use, or not use, the pattern. Think of a [design pattern](https://glossary.magento.com/design-pattern) as a best practice with conditions.
10
+
11
+
Design patterns for service contracts tell you which types of interfaces to define, and how and where to define and implement those interfaces.
11
12
12
13
{: .bs-callout-info }
13
14
Service contract data interfaces are now mutable.
14
15
15
16
## Interface types and locations {#top-level-msc}
16
17
17
-
<p>A [service contract](https://glossary.magento.com/service-contract) must define data interfaces, which preserve data integrity, and service interfaces, which hide business logic from service requestors.</p>
18
-
<p>Data interfaces define functions that return information about data entities, return search results, and set validation rules and return validation results. You must define the data interfaces for a service contract in the <b>Api/Data</b> subdirectory for a [module](https://glossary.magento.com/module).</p>
19
-
<p>
20
-
Service interfaces include management, repository, and [metadata](https://glossary.magento.com/metadata) interfaces.
21
-
You must define the service interfaces for a service contract in the <b>Api</b> subdirectory for a module.<!-- You can substitute another implementation in this directory. -->
22
-
</p>
18
+
A [service contract](https://glossary.magento.com/service-contract) must define data interfaces, which preserve data integrity, and service interfaces, which hide business logic from service requestors.
19
+
20
+
Data interfaces define functions that return information about data entities, return search results, and set validation rules and return validation results. You must define the data interfaces for a service contract in the `Api/Data` subdirectory for a [module](https://glossary.magento.com/module).
21
+
22
+
Service interfaces include management, repository, and [metadata](https://glossary.magento.com/metadata) interfaces.
23
+
You must define the service interfaces for a service contract in the `Api` subdirectory for a module.<!-- You can substitute another implementation in this directory. -->
24
+
23
25
<!--
24
26
<p>For example, the interfaces in the <b>Magento\Customer\Api</b> [namespace](https://glossary.magento.com/namespace) define agreements, or a contract, between clients and implementations of services for the Magento Customer module.
25
27
</p>
26
28
-->
27
29
28
30
## Data interfaces {#data-interfaces}
29
31
30
-
<p>Define data interfaces in the <b>Api/Data</b> subdirectory for a module.</p>
31
-
<p>For example, the data interfaces for the Customer module are in the <b>/app/code/Magento/Customer/Api/Data</b> subdirectory.</p>
32
+
Define data interfaces in the `Api/Data` subdirectory for a module.
33
+
34
+
For example, the data interfaces for the Customer module are in the `/app/code/Magento/Customer/Api/Data` subdirectory.
32
35
33
36
### Data search results interfaces {#search-results-interfaces}
34
37
35
-
<p>When you pass search criteria to a <code>getList()</code> call, a search results interface is returned with the search results.</p>
36
-
<p>You must define one interface for each data [entity](https://glossary.magento.com/entity) for type hinting purposes. That is, the <code>getItems()</code> function in the
37
-
<code>CustomerSearchResultsInterface</code> returns an array of <code>CustomerInterface</code> data entities.
38
-
In <code>GroupSearchResultsInterface</code>, the <code>getItems()</code> function returns an array of <code>GroupInterface</code> data entities.
39
-
</p>
38
+
When you pass search criteria to a `getList()` call, a search results interface is returned with the search results.
39
+
40
+
You must define one interface for each data [entity](https://glossary.magento.com/entity) for type hinting purposes. That is, the `getItems()` function in the
41
+
`CustomerSearchResultsInterface`returns an array of `CustomerInterface` data entities.
42
+
In `GroupSearchResultsInterface`, the `getItems()` function returns an array of `GroupInterface` data entities.
40
43
41
44
## Service interfaces {#service-interfaces}
42
45
43
-
<p>Service interfaces include several interface subtypes:</p>
44
-
<ul>
45
-
<li>Repository interfaces</li>
46
-
<li>Management interfaces</li>
47
-
<li>Metadata interfaces</li>
48
-
</ul>
49
-
<p>For file names and coding standards, follow the defined <ahref="{{ page.baseurl }}/coding-standards/code-standard-php.html">PHP coding standards</a>.</p>
50
-
<p>Place service interfaces in the top-level <b>Api</b> directory for a module.</p>
46
+
Service interfaces include several interface subtypes:
47
+
48
+
- Repository interfaces
49
+
- Management interfaces
50
+
- Metadata interfaces
51
+
52
+
For file names and coding standards, follow the defined [PHP coding standards]({{ page.baseurl }}/coding-standards/code-standard-php.html).
53
+
54
+
Place service interfaces in the top-level `Api` directory for a module.
<p>Repository interfaces provide access to persistent data entities.</p>
55
-
<p>For example, persistent data entities for the Customer module include Customer, Address, and Group. Consequently, repository interfaces for the Customer module are:</p>
56
-
<ul>
57
-
<li><code>CustomerRepositoryInterface</code></li>
58
-
<li><code>AddressRepositoryInterface</code></li>
59
-
<li><code>GroupRepositoryInterface</code></li>
60
-
</ul>
61
-
<p>Repository interfaces must provide these functions:</p>
58
+
Repository interfaces provide access to persistent data entities.
59
+
60
+
For example, persistent data entities for the Customer module include Customer, Address, and Group. Consequently, repository interfaces for the Customer module are:
61
+
62
+
-`CustomerRepositoryInterface`
63
+
-`AddressRepositoryInterface`
64
+
-`GroupRepositoryInterface`
65
+
66
+
Repository interfaces must provide these functions:
67
+
62
68
<tablestyle="width:100%">
63
69
<trbgcolor="lightgray">
64
70
<th>Function</th>
@@ -108,11 +114,13 @@ Service contract data interfaces are now mutable.
108
114
</td>
109
115
</tr>
110
116
</table>
111
-
<p>Each data entity has a corresponding interface. Consequently, the <code>get()</code> function in the corresponding interface, for example, can return the exact type.</p>
117
+
118
+
Each data entity has a corresponding interface. Consequently, the `get()` function in the corresponding interface, for example, can return the exact type.
Copy file name to clipboardExpand all lines: guides/v2.2/extension-dev-guide/service-contracts/service-contracts.md
+15-16Lines changed: 15 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -16,30 +16,29 @@ To address these issues, the Magento system introduces _service contracts_.
16
16
17
17
## What is a service contract? {#what-is-msc}
18
18
19
-
<p>A [service contract](https://glossary.magento.com/service-contract) is a set of [PHP](https://glossary.magento.com/php) interfaces that are defined for a [module](https://glossary.magento.com/module).
20
-
A service contract includes <ahref="{{ page.baseurl }}/extension-dev-guide/service-contracts/design-patterns.html#data-interfaces">data interfaces</a>, which preserve data integrity, and <ahref="{{ page.baseurl }}/extension-dev-guide/service-contracts/design-patterns.html#service-interfaces">service interfaces</a>, which hide business logic details from service requestors such as controllers, web services, and other modules.
21
-
</p>
22
-
<p>If developers define data and service interfaces according to a set of <ahref="{{ page.baseurl }}/extension-dev-guide/service-contracts/design-patterns.html">design patterns</a>, the result is a well-defined, durable [API](https://glossary.magento.com/api) that other modules and third-party extensions can implement through Magento models and resource models.
A [service contract](https://glossary.magento.com/service-contract) is a set of [PHP](https://glossary.magento.com/php) interfaces that are defined for a [module](https://glossary.magento.com/module).
20
+
A service contract includes [data interfaces]({{ page.baseurl }}/extension-dev-guide/service-contracts/design-patterns.html#data-interfaces), which preserve data integrity, and [service interfaces]({{ page.baseurl }}/extension-dev-guide/service-contracts/design-patterns.html#service-interfaces), which hide business logic details from service requestors such as controllers, web services, and other modules.
21
+
22
+
If developers define data and service interfaces according to a set of [design patterns]({{ page.baseurl }}/extension-dev-guide/service-contracts/design-patterns.html), the result is a well-defined, durable [API](https://glossary.magento.com/api) that other modules and third-party extensions can implement through Magento models and resource models.
<p>Service contracts enhance the modularity of Magento. They enable Magento and third-party developers to report system dependencies through <b>composer.json</b> files and, consequently, guarantee compatibility among Magento versions. This compatibility ensures that merchants can easily upgrade Magento.</p>
29
-
<p>These contracts ensure a well-defined, durable API that other modules and third-party extensions can implement. Also, these contracts make it easy to <ahref="{{ page.baseurl }}/extension-dev-guide/service-contracts/service-to-web-service.html">configure services as web APIs</a>.
30
-
</p>
31
-
<p>Data entities are a side benefit of service contracts.
32
-
The database tables that normally support these entities can be complicated.
33
-
For example, some attributes might be stored in an EAV table, so a set of MySQL database tables might define a single data [entity](https://glossary.magento.com/entity).
34
-
Data entities in a service contract reveal a simpler data model than the data model in an underlying relational [database schema](https://glossary.magento.com/database-schema).
35
-
Eventually, you will be able to use different storage technologies for different data collections. For example, you could use a NoSQL database to replace product tables.
36
-
</p>
28
+
Service contracts enhance the modularity of Magento. They enable Magento and third-party developers to report system dependencies through `composer.json` files and, consequently, guarantee compatibility among Magento versions. This compatibility ensures that merchants can easily upgrade Magento.
29
+
These contracts ensure a well-defined, durable API that other modules and third-party extensions can implement. Also, these contracts make it easy to [configure services as web APIs]({{ page.baseurl }}/extension-dev-guide/service-contracts/service-to-web-service.html).
30
+
31
+
Data entities are a side benefit of service contracts.
32
+
The database tables that normally support these entities can be complicated.
33
+
For example, some attributes might be stored in an EAV table, so a set of MySQL database tables might define a single data [entity](https://glossary.magento.com/entity).
34
+
Data entities in a service contract reveal a simpler data model than the data model in an underlying relational [database schema](https://glossary.magento.com/database-schema).
35
+
Eventually, you will be able to use different storage technologies for different data collections. For example, you could use a NoSQL database to replace product tables.
37
36
38
37
## Using the @api tag
39
38
40
39
Backward compatibility can be indicated by the use of `@api`. For more information, see [Backward compatibility]({{ page.baseurl }}/contributor-guide/backward-compatible-development/).
|`name`|Element's index in the scope of the current collection that will be used to build its unique identifier.|String| - |
18
+
|`provider`|Reference to component data provider. For example, for the "New Customer" page on the back-end side it will be equal to `customer_form.customer_form_data_source`|String| - |
19
+
|`sortOrder`|Element's position in the collection|Int|`0`|
20
+
|`template`|The path to the component’s `.html` template.|String|`ui/form/field`|
0 commit comments