Skip to content

Commit 2a54db8

Browse files
authored
Merge pull request #1 from magento-notes/master
Sync with upstream repo
2 parents 1b63b48 + d3eea58 commit 2a54db8

8 files changed

+90
-47
lines changed

1. Magento Architecture and Customization Techniques/3. Utilize configuration XML and variables scope.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
- `address_formats.xml`
77
- `address_types.xml` - format code and title only
88
- `cache.xml` - name, instance - e.g. full_page=Page Cache
9-
- `catalog_attributes.xml` - catalog_category, catalog_product, unassignable, used_in_autogeneration, quote_item
9+
- `catalog_attributes.xml` - catalog_category, catalog_product, unassignable, used_in_autogeneration, quote_item [*](https://www.atwix.com/magento-2/how-to-access-custom-catalog-attributes/)
1010
- `communication.xml`
1111
- `config.xml` - defaults
12-
- `crontab.xml` - group[], job instance, method, schedule
13-
- `cron_groups.xml`
14-
- `di.xml` - preference, plugins, virtual type
12+
- `crontab.xml` - group[], job instance, method, schedule [*](https://github.com/magento-notes/magento2-exam-notes/blob/master/1.%20Magento%20Architecture%20and%20Customization%20Techniques/6.%20Configure%20event%20observers%20and%20scheduled%20jobs.md#crontabxml)
13+
- `cron_groups.xml` [*](https://github.com/magento-notes/magento2-exam-notes/blob/master/1.%20Magento%20Architecture%20and%20Customization%20Techniques/6.%20Configure%20event%20observers%20and%20scheduled%20jobs.md#cron-groups)
14+
- `di.xml` - preference, plugins, virtual type [*](https://devdocs.magento.com/guides/v2.2/extension-dev-guide/build/di-xml-file.html)
1515
- `eav_attributes.xml` - locked entity attributes (global, unique etc.)
1616
- `email_templates.xml` - id label file type module -- view/frontend/email/name.html
17-
- `events.xml` - observers, shared, disabled
17+
- `events.xml` - observers, shared, disabled [*](https://github.com/magento-notes/magento2-exam-notes/blob/master/1.%20Magento%20Architecture%20and%20Customization%20Techniques/6.%20Configure%20event%20observers%20and%20scheduled%20jobs.md#demonstrate-how-to-configure-observers)
1818
- `export.xml`
1919
- `extension_attributes.xml` - for, attribute code, attribute type
2020
- `fieldset.xml`

1. Magento Architecture and Customization Techniques/7. Utilize the CLI.md

+21-10
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,32 @@ This class must extends from [\Symfony\Component\Console\Command\Command](https:
4848
<?php
4949
namespace Vendor\Module\Console\Command;
5050

51+
use Symfony\Component\Console\Input\InputArgument;
52+
use Symfony\Component\Console\Input\InputOption;
53+
5154
class ExampleCommand extends \Symfony\Component\Console\Command\Command
5255
{
5356
protected function configure()
5457
{
55-
$options = [
56-
new \Symfony\Component\Console\Input\InputOption(
57-
'param',
58-
null,
59-
\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED,
60-
'Param description'
61-
),
62-
];
6358
$this->setName('example:hello')
64-
->setDescription('Hello world command')
65-
->setDefinition($options);
59+
->setDescription('Hello world command');
60+
61+
// Positional argument
62+
$this->addArgument(
63+
'myargument',
64+
InputArgument::REQUIRED,
65+
'Positional required argument example'
66+
);
67+
68+
// Not required option
69+
$this->addOption(
70+
'myoption',
71+
null,
72+
InputOption::VALUE_OPTIONAL,
73+
'Option example',
74+
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
75+
);
76+
6677
parent::configure();
6778
}
6879

1. Magento Architecture and Customization Techniques/Magento Architecture and Customization Techniques.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ generate
329329
check for standalone process
330330
```
331331

332-
\Magento\Cron\Model\Config\Data extends \Magento\Cron\Model\Config\Data
332+
`\Magento\Cron\Model\Config\Data` extends `\Magento\Framework\Config\Data`
333333
- merges \Magento\Cron\Model\Config\Reader\Db::get from Database
334334

335335
Sample DB structure:

2. Request Flow Processing/1. Utilize modes and application initialization.md

+39-17
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
- configure autoloader - PSR-4 prepend generation\Magento
1111

12-
\Magento\Framework\App\Bootstrap::*createApplication*
12+
[\Magento\Framework\App\Bootstrap](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/Bootstrap.php)::*createApplication*
1313

1414
- just call object manager->create
1515

16-
\Magento\Framework\App\Bootstrap::*run*
16+
[\Magento\Framework\App\Bootstrap](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/Bootstrap.php)::*run*
1717

1818
- set error handler
1919
- assert maintenance
@@ -27,7 +27,7 @@
2727

2828
### Application class
2929

30-
bootstrap->createApplication()
30+
[bootstrap->createApplication()](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/Bootstrap.php#L230)
3131

3232
- [\Magento\Framework\App\Http](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/Http.php) - index.php, pub/index.php
3333
load config area by front name
@@ -64,19 +64,26 @@ Notes:
6464
[\Magento\Framework\App\Http::launch](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/Http.php#L128)
6565
1. detect config area by front name
6666

67-
`\Magento\Framework\App\AreaList` - areas from argument di.xml
67+
```php
68+
<?php
69+
$areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName());
70+
$this->_state->setAreaCode($areaCode);
71+
$this->_objectManager->configure($this->_configLoader->load($areaCode));
72+
```
73+
74+
`\Magento\Framework\App\AreaList` - areas from argument di.xml ([AreaList](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/AreaList.php))
6875

6976
- frontend = [frontname null, router "standard"] --- *default when nothing matched*
7077
- adminhtml - [frontNameResolver=..., router "admin"]
71-
\Magento\Backend\App\Area\FrontNameResolver::getFrontName(checkhost)
78+
[\Magento\Backend\App\Area\FrontNameResolver::getFrontName(checkhost)](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Backend/App/Area/FrontNameResolver.php#L83)
7279
system config `admin/url/use_custom`, `admin/url/custom`
7380
- crontab = null
7481
- webapi_rest = [frontName `/rest`]
7582
- webapi_soap = [frontname `/soap`]
7683

77-
1. ObjectManagerInterface::configure - selected area code
78-
1. result = FrontControllerInterface->dispatch
79-
1. ResultInterface.renderResult into response object
84+
1. [ObjectManagerInterface->configure()](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php#L82) - selected area code
85+
1. result = FrontControllerInterface->dispatch()
86+
1. [ResultInterface->renderResult()](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/Controller/AbstractResult.php#L122) into response object
8087
1. event `controller_front_send_response_before` (request, response)
8188

8289

@@ -93,9 +100,9 @@ Notes:
93100
- *Default* global preference app/etc/di.xml - Magento\Framework\App\FrontController
94101
- "frontend", "adminhtml", "crontab" area code - no preference, use default *App\FrontController*
95102
- "webapi_rest (frontName `/rest`) - preference module-webapi/etc/webapi_rest/di.xml - *\Magento\Webapi\Controller\Rest*
96-
- "webapi_soap" (frontname `/soap`) - preference module-webapi/etc/webapi_rest/di.xml - *\Magento\Webapi\Controller\Soap*
103+
- "webapi_soap" (frontname `/soap`) - preference module-webapi/etc/webapi_soap/di.xml - *\Magento\Webapi\Controller\Soap*
97104

98-
### [App\FrontController](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/FrontController.php):
105+
### [\Magento\Framework\App\FrontController](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/FrontController.php):
99106

100107
- routerList
101108
- action = router[].match
@@ -111,17 +118,32 @@ Notes:
111118

112119
- [\Magento\Framework\Controller\ResultInterface](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/Controller/ResultInterface.php) - renderResult, setHttpResponseCode, setHeader
113120

114-
Raw, Json, Forward, Layout, Page, Redirect
121+
Implementations:
122+
- [Result\Raw](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/Controller/Result/Raw.php) -> Result\AbstractResult
123+
- [Result\Json](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/Controller/Result/Json.php) -> Result\AbstractResult
124+
- [Result\Forward](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/Controller/Result/Forward.php) -> Result\AbstractResult
125+
- [\Magento\Framework\View\Result\Layout](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/View/Result/Layout.php) -> Result\AbstractResult
126+
- [\Magento\Framework\View\Result\Page](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/View/Result/Page.php) -> \Magento\Framework\View\Result\Layout
127+
- [Result\Redirect](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/Controller/Result/Redirect.php) -> Result\AbstractResult
128+
129+
- [\Magento\Framework\App\ResponseInterface](https://github.com/magento/magento2/blob/2.2-develop/lib/internal//Magento/Framework/App/ResponseInterface.php) - sendResponse
115130

116-
- \Magento\Framework\App\ResponseInterface - sendResponse
117-
Console\Response, Response\FileInterface, PhpEnvironment\Response, Webapi\Response, Rest\Response
131+
Implementations:
132+
- [Console\Response](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/Console/Response.php)
133+
- [\Magento\MediaStorage\Model\File\Storage\FileInterface](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/MediaStorage/Model/File/Storage/Response.php) -> \Magento\Framework\App\Response\Http
134+
- [\Magento\Framework\HTTP\PhpEnvironment\Response](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php) -> \Zend\Http\PhpEnvironment\Response
135+
- [\Magento\Framework\Webapi\Response](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/Webapi/Response.php) -> \Magento\Framework\HTTP\PhpEnvironment\Response
136+
- [\Magento\Framework\Webapi\Rest\Response](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/Webapi/Rest/Response.php) -> \Magento\Framework\Webapi\Response
118137

119-
### [Controller\Rest](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Webapi/Controller/Rest.php):
120-
- process path [/$store]/... - specific store, [/all]/... - admin store, /... - default store
138+
### [\Magento\Webapi\Controller\Rest](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Webapi/Controller/Rest.php) -> \Magento\Framework\App\FrontControllerInterface:
139+
140+
- preference for FrontController set in [etc/webapi_rest/di.xml](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Webapi/etc/webapi_rest/di.xml#L32)
141+
- process path [/$store]/... - specific store, [/all]/... - admin store (0), /... - default store
121142
- a. process schema request /schema
122-
- b. or process api request (resolve route, invoike route -> service class with params)
143+
- b. or process api request (resolve route, invoke route -> service class with params)
144+
145+
### [\Magento\Webapi\Controller\Soap](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Webapi/Controller/Soap.php) -> \Magento\Framework\App\FrontControllerInterface:
123146

124-
### [Controller\Soap](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Webapi/Controller/Soap.php):
125147
- process path (same as REST)
126148
- a. generate WSDL ?wsdl
127149
- b. or generate WSDL service list ?wsdl_list

2. Request Flow Processing/2. Demonstrate ability to process URLs in Magento.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ Module UrlRewrite:
8787

8888
Product:
8989

90-
- event `catalog_product_save_before`
90+
- event `catalog_product_save_before` - generate URL key by product name (if url key wasn't provided)
91+
* [ProductUrlKeyAutogeneratorObserver](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/CatalogUrlRewrite/Observer/ProductUrlKeyAutogeneratorObserver.php)
92+
* [\Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::getUrlKey](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlPathGenerator.php#L125)
93+
94+
- event `catalog_product_save_after` - generate and replace URL rewrites (when changed url_key, categories, websites or visibility)
9195
* [ProductProcessUrlRewriteSavingObserver](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/CatalogUrlRewrite/Observer/ProductProcessUrlRewriteSavingObserver.php)
92-
* \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator::generate
96+
* [\Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator::generate](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php#L128)
9397
* deleteByData, replace
9498

9599
Category:
@@ -102,6 +106,8 @@ Category:
102106
* child category.url_path
103107

104108
- event `catalog_category_save_after` - when changed (key, anchor, products)
109+
* [CategoryProcessUrlRewriteSavingObserver](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/CatalogUrlRewrite/Observer/CategoryProcessUrlRewriteSavingObserver.php#L90)
110+
* [\Magento\CatalogUrlRewrite\Observer\UrlRewriteHandler::generateProductUrlRewrites](https://github.com/magento/magento2/blob/2.2-develop/app/code//Magento/CatalogUrlRewrite/Observer/UrlRewriteHandler.php#L124)
105111
* ... lots of logic
106112

107113

2. Request Flow Processing/3. Demonstrate ability to customize request routing.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Describe request routing and flow in Magento.
44

5-
Frontend routers:
5+
[Frontend routers](https://devdocs.magento.com/guides/v2.2/extension-dev-guide/routing.html):
66

77
- robots (10)
88
- urlrewrite (20)
@@ -41,13 +41,17 @@ reference route by ID and add own module "before" original module.
4141

4242
### How do you handle custom 404 pages?
4343

44-
1. If front controller catches NotFoundException, it changes action name *"noroute"* and continues loop.
44+
1. If [front controller](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/FrontController.php#L61-L65) catches [\Magento\Framework\Exception\NotFoundException](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/Exception/NotFoundException.php), it changes action name *"noroute"* and continues loop.
4545
E.g. catalog/product/view/id/1 throws NotFoundException. catalog/product/noroute is checked.
4646

4747
1. If standard router recognizes front name but can't find controller, it tries to find *"noroute"*
4848
action from last checked module.
4949
E.g. catalog/brand/info controller doesn't exist, so catalog/brand/noroute will be checked.
50+
51+
[\Magento\Framework\App\Router\Base::getNotFoundAction](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/Router/Base.php#L237)
5052

5153
1. If all routers didn't match, default controller provides two opportunities:
52-
- set default 404 route in admin config `web/default/no_route`
53-
- register custom handler in noRouteHandlerList
54+
- set default 404 route in admin config `web/default/no_route` (see: [\Magento\Framework\App\Router\NoRouteHandler::process](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/Router/NoRouteHandler.php#L34))
55+
- register custom handler in [noRouteHandlerList](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/Router/NoRouteHandlerList.php):
56+
* backend (sortOrder: 10) [Magento\Backend\App\Router\NoRouteHandler](https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Backend/App/Router/NoRouteHandler.php#L44) -> `adminhtml/noroute/index`
57+
* default (sortOrder: 100) [Magento\Framework\App\Router\NoRouteHandler](https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/App/Router/NoRouteHandler.php)

2. Request Flow Processing/4. Determine the layout initialization process.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ View\Layout::*build* = View\Layout\Builder::*build* - once
1010

1111
1. generateLayoutXml - joins `_updates` into XML string, loads XML object, initiailzes `_elements` = []
1212

13-
* layout.generaXml
13+
* layout.generateXml
1414
* no events
1515

1616
1. generateLayoutBlocks - layout.generateElements
@@ -213,11 +213,11 @@ Only containers
213213

214214

215215
### page result.renderResult:
216-
- View\Resuls\PageFactory.create
216+
- View\Result\PageFactory.create
217217
- View\Result\Page::addDefaultHandle - `default`, `$fullActionName`
218218

219219
- View\Page\Config.publicBuild = build
220-
- View\Page\Builder.build - extends View\Layout\Builder, custom readPageLayout on step generatelayoutBlocks
220+
- View\Page\Builder.build - extends View\Layout\Builder, custom readPageLayout on step generateLayoutBlocks
221221

222222
* (inherit) loadLayoutUpdates
223223
* (inherit) generateLayoutXml

3. Customizing the Magento UI/1. Demonstrate ability to utilize themes and the template structure.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ All same as layout, but subDir 'page_layout':
244244
<theme>*_*/page_layout/override/theme/*/*/*.xml
245245
```
246246

247-
View\Layout\ProcessorInterface = View\Model\Layout\Merg
247+
View\Layout\ProcessorInterface = View\Model\Layout\Merge
248248
- $updates - array of all found string XML file contents E.g.
249249
```
250250
updates[] = '<body><block name="someBlock"...'
@@ -260,8 +260,8 @@ View\Layout\ProcessorInterface = View\Model\Layout\Merg
260260
- create new theme from scratch without parent when design is very different from existing
261261
- inherit new theme to add smaller customizations - move, hide, reorder elements, change block arguments, html attributes
262262
- new theme can be assigned to specific store view, for example for b2b store
263-
- theme can apply dynamically based on browser user agent as exception - enter regexp
264-
Content > Design > Implementation > [Edit] > Design Rule > User Agent Rules
263+
- theme can apply dynamically based on browser user agent as exception - enter regexp in
264+
_Content > Design > Implementation > [Edit] > Design Rule > User Agent Rules_
265265
Full page cache and design exception:
266266
```
267267
plugin magento-store/etc/di.xml:
@@ -285,9 +285,9 @@ View\Layout\ProcessorInterface = View\Model\Layout\Merg
285285

286286
theme.xml - parent
287287

288-
Determine theme hierarch of existing project:
288+
Determine theme hierarchy of existing project:
289289

290-
- Go to Content > Design > Configuration
290+
- Go to _Content > Design > Configuration_
291291
- Check "Theme Name" column on row with store view under question
292292
- find paths to all available themes in app/etc/design/frontend/* or vendor/*/theme-* (conventionally)
293293
or find programmatically:

0 commit comments

Comments
 (0)