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

Commit 296de4a

Browse files
Fixed code block style (MD040) in the Extension Developer Guide (#5434)
* Fixed errors in the extension dev guide * Fixed php code block
1 parent ee5a783 commit 296de4a

File tree

19 files changed

+188
-112
lines changed

19 files changed

+188
-112
lines changed

guides/v2.2/ext-best-practices/extension-coding/example-module-adminpage.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ In the module's root directory, create the file `composer.json`. This file gives
3636
For more information see: [`composer.json`]({{ page.baseurl }}/extension-dev-guide/build/composer-integration.html).
3737

3838
{% collapsible File content for composer.json %}
39+
3940
```json
4041
{
4142
"name": "mycompany/sample-module-minimal",
@@ -57,6 +58,7 @@ For more information see: [`composer.json`]({{ page.baseurl }}/extension-dev-gui
5758
}
5859
}
5960
```
61+
6062
{% endcollapsible %}
6163

6264
#### `registration.php`
@@ -66,6 +68,7 @@ In the module's root directory, create the file `registration.php`. This file re
6668
For more information see: [registering your component]({{ page.baseurl }}/extension-dev-guide/build/component-registration.html).
6769

6870
{% collapsible File content for registration.php %}
71+
6972
```php
7073
<?php
7174
\Magento\Framework\Component\ComponentRegistrar::register(
@@ -74,6 +77,7 @@ For more information see: [registering your component]({{ page.baseurl }}/extens
7477
__DIR__
7578
);
7679
```
80+
7781
{% endcollapsible %}
7882

7983
#### `etc/module.xml`
@@ -83,13 +87,15 @@ In the module's root directory, create a new directory called `etc`. Under that
8387
For more information see: [naming your component]({{ page.baseurl }}/extension-dev-guide/build/create_component.html).
8488

8589
{% collapsible File content for module.xml %}
90+
8691
```xml
8792
<?xml version="1.0"?>
8893
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
8994
<module name="MyCompany_ExampleAdminNewPage" setup_version="1.0.0">
9095
</module>
9196
</config>
9297
```
98+
9399
{% endcollapsible %}
94100

95101
### Routing and navigation
@@ -117,6 +123,7 @@ The following parts make up the generated page request link to the **Hello World
117123

118124
[//]: # (Stop list rendering before collapsible, see: https://github.com/magento/devdocs/issues/2655)
119125
{% collapsible File content for menu.xml %}
126+
120127
```xml
121128
<?xml version="1.0"?>
122129
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
@@ -126,13 +133,15 @@ The following parts make up the generated page request link to the **Hello World
126133
</menu>
127134
</config>
128135
```
136+
129137
{% endcollapsible %}
130138

131139
#### `etc/adminhtml/routes.xml`
132140
{:.no_toc}
133141
Under `etc/adminhtml` create the file `routes.xml`. The contents of this XML file tells Magento to route requests that use the `frontName` `exampleadminnewpage` to this module.
134142

135143
{% collapsible File content for routes.xml %}
144+
136145
```xml
137146
<?xml version="1.0"?>
138147
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
@@ -143,6 +152,7 @@ Under `etc/adminhtml` create the file `routes.xml`. The contents of this XML fi
143152
</router>
144153
</config>
145154
```
155+
146156
{% endcollapsible %}
147157

148158
### Page controller
@@ -159,6 +169,7 @@ mkdir -p Controller/Adminhtml/HelloWorld
159169

160170
Inside `Controller/Adminhtml/HelloWorld` directory, create the file `Index.php`. This file is the class assigned to the default Index action for the `HelloWorld` controller. Since the admin area serves this page, the file belongs in the `Adminhtml` directory, and the class itself extends [`\Magento\Backend\App\Action`]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Backend/App/Action.php){:target="_blank"}.
161171
{% collapsible File content for Index.php %}
172+
162173
```php
163174
<?php
164175
namespace MyCompany\ExampleAdminNewPage\Controller\Adminhtml\HelloWorld;
@@ -196,6 +207,7 @@ Inside `Controller/Adminhtml/HelloWorld` directory, create the file `Index.php`.
196207
}
197208
?>
198209
```
210+
199211
{% endcollapsible %}
200212

201213
### Page view
@@ -219,6 +231,7 @@ This file defines the [layout](https://glossary.magento.com/layout) and structur
219231
The name of this file uses the following pattern: *routeId*\_*controller*\_*action*.xml
220232

221233
{% collapsible File content for exampleadminnewpage_helloworld_index.xml %}
234+
222235
```xml
223236
<?xml version="1.0"?>
224237
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
@@ -234,6 +247,7 @@ The name of this file uses the following pattern: *routeId*\_*controller*\_*acti
234247
</body>
235248
</page>
236249
```
250+
237251
{% endcollapsible %}
238252

239253
#### `view/adminhtml/templates/helloworld.phtml`
@@ -242,9 +256,11 @@ The name of this file uses the following pattern: *routeId*\_*controller*\_*acti
242256
This template file contains the actual page content for the **Hello World** page.
243257

244258
{% collapsible File content for helloworld.phtml %}
259+
245260
```html
246261
<p>Hello World!</p>
247-
```
262+
```
263+
248264
{% endcollapsible %}
249265

250266
### Full module directory structure

guides/v2.2/extension-dev-guide/build/module-file-structure.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Additional folders can be added for configuration and other ancillary functions
4545

4646
A typical [theme](https://glossary.magento.com/theme) file structure can look like the following:
4747

48-
~~~
48+
```tree
4949
├── composer.json
5050
├── etc
5151
│   └── view.xml
@@ -81,7 +81,7 @@ A typical [theme](https://glossary.magento.com/theme) file structure can look li
8181
├── navigation-menu.js
8282
├── responsive.js
8383
└── theme.js
84-
~~~
84+
```
8585

8686
#### Common directories
8787
{:.no_toc}

guides/v2.2/extension-dev-guide/cache/page-caching/public-content.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ For another example of a context class, see [Magento/Framework/App/Http/Context]
117117

118118
Use the `X-Magento-Vary` cookie to transfer context on the HTTP layer. HTTP proxies can be configured to calculate a unique identifier for cache based on the cookie and URL. For example, [our sample Varnish 4 configuration]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/PageCache/etc/varnish4.vcl#L63-L68){:target="_blank"} uses the following:
119119

120-
```
120+
```conf
121121
sub vcl_hash {
122122
if (req.http.cookie ~ "X-Magento-Vary=") {
123123
hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1"));

guides/v2.2/extension-dev-guide/cache/partial-caching/database-caching.md

Lines changed: 61 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,18 @@ To modify `di.xml`:
3636
1. Log in to the Magento server as, or switch to, the [Magento file system owner].
3737
2. Enter the following commands to make a copy of `di.xml`:
3838

39-
cd <magento_root>/app/etc
40-
cp di.xml di.xml.bak
39+
```bash
40+
cd <magento_root>/app/etc
41+
```
42+
43+
```bash
44+
cp di.xml di.xml.bak
45+
```
4146

4247
3. Open `di.xml` in a text editor and locate the following block:
4348

44-
<type name="Magento\Framework\App\Cache\Frontend\Pool">
49+
```xml
50+
<type name="Magento\Framework\App\Cache\Frontend\Pool">
4551
<arguments>
4652
<argument name="frontendSettings" xsi:type="array">
4753
<item name="page_cache" xsi:type="array">
@@ -59,6 +65,7 @@ To modify `di.xml`:
5965
</argument>
6066
</arguments>
6167
</type>
68+
```
6269

6370
The `<type name="Magento\Framework\App\Cache\Frontend\Pool">` node configures options for the in-memory pool of all frontend cache instances.
6471

@@ -67,26 +74,26 @@ To modify `di.xml`:
6774
4. Replace the entire block with the following:
6875

6976
```xml
70-
<type name="Magento\Framework\App\Cache\Frontend\Pool">
71-
<arguments>
72-
<argument name="frontendSettings" xsi:type="array">
73-
<item name="page_cache" xsi:type="array">
77+
<type name="Magento\Framework\App\Cache\Frontend\Pool">
78+
<arguments>
79+
<argument name="frontendSettings" xsi:type="array">
80+
<item name="page_cache" xsi:type="array">
7481
<item name="backend" xsi:type="string">database</item>
7582
</item>
7683
<item name="<your cache id>" xsi:type="array">
7784
<item name="backend" xsi:type="string">database</item>
7885
</item>
79-
</argument>
80-
</arguments>
81-
</type>
82-
<type name="Magento\Framework\App\Cache\Type\FrontendPool">
83-
<arguments>
84-
<argument name="typeFrontendMap" xsi:type="array">
85-
<item name="backend" xsi:type="string">database</item>
86-
</argument>
87-
</arguments>
88-
</type>
89-
```
86+
</argument>
87+
</arguments>
88+
</type>
89+
<type name="Magento\Framework\App\Cache\Type\FrontendPool">
90+
<arguments>
91+
<argument name="typeFrontendMap" xsi:type="array">
92+
<item name="backend" xsi:type="string">database</item>
93+
</argument>
94+
</arguments>
95+
</type>
96+
```
9097

9198
where `<your cache id>` is your unique cache identifier.
9299

@@ -106,30 +113,37 @@ To enable database caching using a custom cache frontend, you must modify `<mage
106113
1. Log in to the Magento server as, or switch to, the [Magento file system owner].
107114
2. Enter the following commands to make a copy of `env.php`:
108115

109-
cd <magento_root>/app/etc
110-
cp env.php env.php.bak
116+
```bash
117+
cd <magento_root>/app/etc
118+
```
119+
120+
```bash
121+
cp env.php env.php.bak
122+
```
111123

112124
3. Open `env.php` in a text editor and add the following anywhere, such as before `'cache_types' =>`:
113125

114-
'cache' => [
115-
'frontend' => [
116-
'<unique frontend id>' => [
117-
<cache options>
118-
],
119-
],
120-
'type' => [
121-
<cache type 1> => [
122-
'frontend' => '<unique frontend id>'
123-
],
124-
],
125-
'type' => [
126-
<cache type 2> => [
127-
'frontend' => '<unique frontend id>'
128-
],
129-
],
130-
],
131-
132-
An example is shown in [Configuration examples].
126+
```php
127+
'cache' => [
128+
'frontend' => [
129+
'<unique frontend id>' => [
130+
<cache options>
131+
],
132+
],
133+
'type' => [
134+
<cache type 1> => [
135+
'frontend' => '<unique frontend id>'
136+
],
137+
],
138+
'type' => [
139+
<cache type 2> => [
140+
'frontend' => '<unique frontend id>'
141+
],
142+
],
143+
],
144+
```
145+
146+
An example is shown in [Configuration examples].
133147

134148
4. Save your changes to `env.php` and exit the text editor.
135149
5. Continue with the next section.
@@ -144,16 +158,21 @@ Use the following steps:
144158
2. Clear the current cache directories:
145159

146160
```bash
147-
rm -rf <magento_root>/var/cache/* <magento_root>/var/page_cache/* <magento_root>/generated/metadata/* <magento_root>/generated/code/*
161+
rm -rf <magento_root>/var/cache/* <magento_root>/var/page_cache/* <magento_root>/generated/metadata/* <magento_root>/generated/code/*
148162
```
149163

150164
3. In a web browser, go to any cacheable page (such as the [storefront](https://glossary.magento.com/storefront) front door page).
151165

152166
If exceptions display, verify `di.xml` syntax and try again. (To see exceptions in the browser, you must [enable developer mode].)
153167
4. Enter the following commands:
154168

155-
ls <magento_root>/var/cache/*
156-
ls <magento_root>/var/page_cache/*
169+
```bash
170+
ls <magento_root>/var/cache/*
171+
```
172+
173+
```bash
174+
ls <magento_root>/var/page_cache/*
175+
```
157176

158177
{:.bs-callout .bs-callout-info }
159178
Due to a known issue, a custom cache frontend still results in some objects being cached to the file system; however, fewer assets are cached compared to file system caching.

guides/v2.2/extension-dev-guide/cli-cmds/cli-howto.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,13 @@ You can style the output text by using `<error>This is an error message</error>`
9595

9696
3. Clean the [cache](https://glossary.magento.com/cache) and compiled code directories:
9797

98-
cd <magento_root>/var
99-
rm -rf cache/* page_cache/* di/* generation/*
98+
```bash
99+
cd <magento_root>/var
100+
```
101+
102+
```bash
103+
rm -rf cache/* page_cache/* di/* generation/*
104+
```
100105

101106
## Add CLI commands using the Composer autoloader {#cli-autoload}
102107

@@ -105,4 +110,3 @@ To be added at a later time.
105110
#### Related topic
106111

107112
[Command naming guidelines]({{ page.baseurl }}/extension-dev-guide/cli-cmds/cli-naming-guidelines.html)
108-

0 commit comments

Comments
 (0)