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

Commit a8ee23d

Browse files
committed
Merge pull request #2 from Magento/pubs4009_Vendor
Component Registration Pubs4009_Vendor
2 parents 157dc5e + 71195eb commit a8ee23d

10 files changed

+131
-39
lines changed
4.72 KB
Loading

guides/v2.0/extension-dev-guide/Contribute_edg.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,25 @@
22
layout: default
33
group: Contributor Guide
44
subgroup:
5-
title: Contribute to Magento DevDocs!
6-
menu_title: Contribute to Magento DevDocs!
5+
title: Contribute to Magento DevDocs
6+
menu_title: Contribute to Magento DevDocs
77
menu_order: 100
8+
github_link: extension-dev-guide/Contribute_edg.md
89

910
---
1011

11-
We encourage our community members to add content; either by writing a full topic, adding new sections to existing topic, or even just adding a few sentences about something you know on an existing topic. Don't worry about perfect grammar or form; just get your brilliance down!!
12+
We encourage our users to add or correct Magento DevDoc content. Write a full topic, add a new section to an existing topic, or even just add a few sentences about something you know on an existing topic. Don't worry about grammar or form; we can fix that for you!
1213

13-
The files are mostly written in the markdown language (and HTML where needed).
14+
Magento Devdocs site content is written in [Markdown](https://daringfireball.net/projects/markdown/), and is kept in Github. If you know how to use Github, you can contribute to our docs.
1415

15-
To get started, review the <a href="{{ site.gdeurl }}contributor-guide/contributing.html">Contributor Guide</a> to learn about the process for code and doc contributions, including how to fork the repository and do a Pull Request to have your work submitted and reviewed.
16+
Review the Table of Contents in the left pane of the Guide, and determine which topic areas you can contribute to, or any that might be missing.
1617

17-
Then, review the Table of Contents in the left pane of the Guide, and determine which topic areas you can contribute to, or any that might be missing.
18-
19-
To add your knowledge to our Docs, you can:
18+
To add to Magento Docs:
2019

2120
* edit your local version of an existing file
2221
* use the <a href="{{ site.githuburl }}template.md">generic template</a> and write a brand new topic, we will find the right home for it in the appropriate Guide.
2322
* use an existing, empty template to write about a topic that we know we need, but haven't yet gotten around to writing
23+
* Create a Pull Request to have your contribution reviewed by the DevDocs team.
2424

25-
26-
Create a Pull Request to have your contribution reviewed by the DevDocs team.
27-
28-
Your contributions to our Docs and your experience with using Magento are very valued and appreciated. Let us know if you have any questions!
25+
Your contributions to Magento Docs informed by your experience with using Magento are highly valued and appreciated. Let us know if you have any questions!
2926

guides/v2.0/extension-dev-guide/build.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The following details the module building process:
2424

2525
* [Module file structure](module-file-structure.html)
2626
* [Define your configuration files](required-configuration-files.html)
27+
* [Component registration](component-registration.html)
2728
* [Create your module](create_module.html)
2829
* [Module load order](module-load-order.html)
2930
* [Enable your module](enable-module.html)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
layout: default
3+
group: extension-dev-guide
4+
subgroup: 3_Build
5+
title: Component registration
6+
menu_title: Component registration
7+
menu_order: 4
8+
github_link: extension-dev-guide/composer-integration.md
9+
redirect_from: /guides/v1.0/extension-dev-guide/composer-integration.html
10+
11+
---
12+
##{{page.menu_title}}
13+
14+
15+
Magento components, including modules, themes, and languages, must be registered in the Magento system through the Magento `ComponentRegistrar` class.
16+
17+
Each component must have a file called `registration.php` in its root directory. For example, here is the `registration.php` file for Magento's [AdminNotification module](https://github.corp.ebay.com/magento2/magento2ce/blob/develop/app/code/Magento/AdminNotification/registration.php). Depending on the type of component, registration is performed through `registration.php` by adding to it as follows:
18+
19+
###Modules
20+
21+
Modules are registered with:
22+
23+
ComponentRegistrar::register(ComponentRegistrar::MODULE, '<VendorName_ModuleName>', __DIR__);
24+
25+
where &lt;VendorName> is the name of the company providing the module and &lt;ModuleName> is the name of the module.
26+
27+
#####Example
28+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_AdminNotification', __DIR__);
29+
<p>&nbsp;</p>
30+
31+
32+
###Themes
33+
34+
Themes are registered with:
35+
36+
ComponentRegistrar::register(ComponentRegistrar::THEME, '<area>/<vendor>/<theme name>', __DIR__);
37+
38+
where &lt;area> is the functional area of the module (frontend, controller, and so on.), &lt;vendor> is the name of the company providing the theme, and &lt;theme name> is the name of the theme.
39+
40+
41+
#####Example
42+
ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/Magento/luma', __DIR__);
43+
44+
<p>&nbsp;</p>
45+
46+
47+
###Languages
48+
Languages are registered with:
49+
50+
ComponentRegistrar::register(ComponentRegistrar::LANGUAGE, '<VendorName>_<packageName>', __DIR__);
51+
52+
where &lt;VendorName> is the name of the company providing the package and &lt;packageName> is the name of the package.
53+
54+
#####Example
55+
ComponentRegistrar::register(ComponentRegistrar::LANGUAGE, 'magento_de_de', __DIR__);
56+
57+
<p>&nbsp;</p>
58+
59+
###Invoke registration.php in composer.json
60+
61+
After you create your `registration.php` file and you are creating [your module's composer.json file](create_module.html#add-the-module8217s-composerjson-file), remember to invoke your `registration.php` file in the autoload section of `composer.json`:
62+
63+
{
64+
"name": "Acme-vendor/bar-component",
65+
"autoload": {
66+
"psr-4": { "AcmeVendor\\BarComponent\\": "" },
67+
"files": [ "registration.php" ]
68+
}
69+
}
70+
71+
<p>&nbsp;</p>
72+
73+
##Sample registration.php file
74+
75+
{% highlight php startinline=true %}
76+
<?php
77+
/**
78+
* Copyright © 2015 Magento. All rights reserved.
79+
* See COPYING.txt for license details.
80+
*/
81+
\Magento\Framework\Component\ComponentRegistrar::register(
82+
\Magento\Framework\Component\ComponentRegistrar::MODULE,
83+
'Magento_AdminNotification',
84+
__DIR__
85+
);
86+
87+
{%endhighlight %}
88+
89+
##Next
90+
91+
[Create a module](create_module.html)

guides/v2.0/extension-dev-guide/create_module.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ group: extension-dev-guide
44
subgroup: 3_Build
55
title: Create a module
66
menu_title: Create a module
7-
menu_order: 4
7+
menu_order: 5
88
github_link: extension-dev-guide/create_module.md
99
redirect_from: /guides/v1.0/extension-dev-guide/create_module.html
1010
---
1111
##{{page.menu_title}}
1212

13-
Now that you have [determined your module&#8217;s initial file structure](module-file-structure.html) and have an idea of the [configuration files](required-configuration-files.html) you&#8217;ll need, you can create the module.
13+
Now that you have [determined your module&#8217;s initial file structure](module-file-structure.html), have an idea of the [configuration files](required-configuration-files.html) you&#8217;ll need, and you've [registered your module](component-registration.html), you can create the module.
14+
15+
1416

1517
##Add the module&#8217;s `module.xml` file
1618
Declare the module itself by adding a module.xml file in the `/etc` folder of your module.
@@ -31,7 +33,10 @@ The smallest working module.xml file would look something like this:
3133

3234

3335
{
34-
"name": "your-name/module-foobar",
36+
"name": "your-name/module-Acme",
37+
"autoload": {
38+
"psr-4": { "AcmeVendor\\BarComponent\\": "" },
39+
"files": [ "registration.php" ],
3540
"description": "Test module for Magento 2",
3641
"require": {
3742
"php": "~5.5.0|~5.6.0",

guides/v2.0/extension-dev-guide/enable-module.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ group: extension-dev-guide
44
subgroup: 3_Build
55
title: Enable a module
66
menu_title: Enable a module
7-
menu_order: 6
7+
menu_order: 7
88
github_link: extension-dev-guide/enable-module.md
99

1010
---

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ github_link: extension-dev-guide/module-file-structure.md
1010
---
1111
##{{page.menu_title}}
1212

13-
Magento 2 looks for the files that make up a module, including configuration files, in particular places. Follow the predefined file structure to ensure that your module works as expected.
13+
Magento 2 looks for the files that make up a module, including configuration files, in particular places inside the module file structure. Follow the predefined file structure to ensure that your module works as expected.
1414

15+
A module can live anywhere under the Magento root directory. Regardless of where you add it, you must [register the module's location](component-registration.html).
1516

16-
###Magento 2 Module File Structure
17+
18+
19+
20+
###Magento 2 Module File structure
1721

1822

1923
A typical file structure for a Magento 2 module:
@@ -60,7 +64,8 @@ You can add subfolders inside your module folder as you need them (Block, Contro
6064

6165
Or, you could just add them at once:
6266

63-
mkdir Api && mkdir Block && mkdir Controller && mkdir etc && mkdir Helper && mkdir i18n && mkdir Model && mkdir view
67+
mkdir Api Block Controller etc Helper i18n Model view
68+
6469

6570
Make sure you add the `etc` folder; it is required, and is where most of the configuration files, including `module.xml`, are kept.
6671

guides/v2.0/extension-dev-guide/module-load-order.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ group: extension-dev-guide
44
subgroup: 3_Build
55
title: Module load order
66
menu_title: Module load order
7-
menu_order: 5
7+
menu_order: 6
88
github_link: extension-dev-guide/module-load-order.md
99

1010
---

guides/v2.0/extension-dev-guide/prepare.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ Before you start building Magento modules, make sure you&#8217;ve got Magento an
1717

1818
* [Install Magento and any required dependencies]({{ site.gdeurl }}/install-gde/bk-install-guide.html)
1919
* [Composer integration](composer-integration.html)
20+
* [Component registration](component-resgistration.html)
2021
* [Set your mode to developer]({{ site.gdeurl }}/config-guide/bootstrap/magento-how-to-set.html)
2122
<!-- * [Determine your file structure](x) -->

guides/v2.0/extension-dev-guide/required-configuration-files.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,10 @@ Magento 2 looks for configuration information for each module in that module&#82
4646
In addition to those files, a Magento 2 module also has nested configuration folders in the `etc` folder for any required administration html, frontend, API REST, or API SOAP specific configuration. Additions you make to files in these folders override the settings in the global configuration files for the respective functionality only. That is, if you add a `config.xml` file to `etc/frontend`, the settings you make in that file overrides the settings in `etc/config.xml` __only for frontend__ functionality.
4747

4848

49-
* _YourModule_/etc/adminhtml/
50-
* _YourModule_/etc/frontend/
51-
* _YourModule_/etc/webapi_rest/
52-
* _YourModule_/etc/webapi_soap/
53-
54-
55-
If you want to just create the basic set of folders and files in etc that you might need, you could enter the following at the command line:
56-
57-
58-
cd etc
59-
60-
mkdir adminhtml && mkdir frontend && mkdir webapi_rest && mkdir webapi_soap && touch acl.xml config.xml di.xml module.xml webapi.xml
49+
* &lt;YourModule>/etc/adminhtml/
50+
* &lt;YourModule>/etc/frontend/
51+
* &lt;YourModule>/etc/webapi_rest/
52+
* &lt;YourModule>/etc/webapi_soap/
6153

6254

6355

@@ -74,18 +66,18 @@ If you want to just create the basic set of folders and files in etc that you mi
7466

7567
The exact set of configuration files required for your module depends on what your new module does. The required configuration files depend on how you plan to use the module: will the module be manifested on the storefront UI, or in the Magento Admin panel, or as a backend extension that makes a service call? Or all of the above. For example, if your module performs a function in the Admin, you should add any necessary configuration files for those functions to `etc/adminhtml/`, like:
7668

77-
* <code><em>YourModule</em>/etc/adminhtml/di.xml</code>
78-
* <code><em>YourModule</em>/etc/adminhtml/routes.xml</code>
69+
* <code>&lt;YourModule>/etc/adminhtml/di.xml</code>
70+
* <code>&lt;YourModule>/etc/adminhtml/routes.xml</code>
7971

8072
Similarly, if your module changes the UI, you should add the needed configuration files to `~/etc/frontend/`. For example:
8173

82-
* <code><em>YourModule</em>/etc/frontend/.xml</code>
83-
* <code><em>YourModule</em>/etc/frontend/page_types.xml</code>
74+
* <code>&lt;YourModule>/etc/frontend/.xml</code>
75+
* <code>&lt;YourModule>/etc/frontend/page_types.xml</code>
8476

8577
If the module is a service that may call an API, or does some other work that is not manifested in the UI you should add any needed configuration files in the REST and/or SOAP webapi configuration folders, like this:
8678

87-
* <code><em>YourModule</em>/etc/webapi_rest/di.xml</code>
88-
* <code><em>YourModule</em>/etc/webapi_soap/di.xml</code>
79+
* <code>&lt;YourModule>/etc/webapi_rest/di.xml</code>
80+
* <code>&lt;YourModule>/etc/webapi_soap/di.xml</code>
8981

9082
Keep in mind that you may be able to handle your module&#8217;s configuration solely with configuration files at the top level of your module&#8217;s `etc` folder, but the nested folder is a useful way to keep the configuration neatly compartmentalized.
9183

@@ -105,6 +97,6 @@ Keep in mind that you may be able to handle your module&#8217;s configuration so
10597

10698
##Next
10799

108-
[Create a module](create_module.html)
100+
[Component Registration](component-registration.html)
109101

110102

0 commit comments

Comments
 (0)