Skip to content
Snippets Groups Projects
Commit e829deda authored by Seamus Lee's avatar Seamus Lee Committed by GitHub
Browse files

Merge pull request #356 from dvhirst/patch-22

Update structure.md
parents a58ec198 51d5bb55
No related branches found
No related tags found
No related merge requests found
...@@ -4,41 +4,27 @@ ...@@ -4,41 +4,27 @@
The [civix](/extensions/civix.md) command line tool will generate the following structure The [civix](/extensions/civix.md) command line tool will generate the following structure
for you: for you:
- ***info.xml*** is a manifest that describes your extension – the - ***info.xml*** is a manifest that describes your extension – the name, license, version number, etc. You should edit most information in this file. The information contained in this file will also be used if published on civicrm.org.
name, license, version number, etc. You should edit most information - ***myextension.php*** stores source code for all your hooks. It includes a few default hook implementations which will make development easier. You can add and remove hooks as you wish. (Note: This file name is different in each module – it is based the module's *[short-name](/extensions/index.md#extension-names)*.)
in this file. The information contained in this file will also be used if published on civicrm.org - ***myextension.civix.php*** contains auto-generated helper functions. These deal with common problems like registering your
- ***myextension.php*** stores source code for all your hooks. It module in the template include-path. `civix` may automatically overwrite this file, so generally do not edit it.
includes a few default hook implementations which will make
development easier. You can add and remove hooks as you wish. (Note:
This file name is different in each module – it is based the
module's *[short-name](/extensions/index.md#extension-names)*.)
- ***myextension.civix.php*** contains auto-generated helper
functions. These deal with common problems like registering your
module in the template include-path. `civix` may automatically
overwrite this file, so generally do not edit it.
## Extension Directory Structure ## Extension Directory Structure
In addition, civix creates some empty directories. These directories are In addition, civix creates some empty directories. These directories are reminiscent of the directory structure in CiviCRM core:
reminiscent of the directory structure in CiviCRM core:
- ***CRM/Myextension/*** stores PHP class files. Classes in this - ***CRM/Myextension/*** stores PHP class files. Classes in this folder should be prefixed with "CRM\_Myextension\_".
folder should be prefixed with "CRM\_Myextension\_"
- ***templates/*** stores Smarty templates. - ***templates/*** stores Smarty templates.
- ***xml/*** stores XML configuration files (such as URL routes and schema xml) - ***xml/*** stores XML configuration files (such as URL routes and schema xml).
- ***build/*** stores exportable .zip files - ***build/*** stores exportable .zip files.
When adding files into these directories it is advisable to follow similar patterns to that in CiviCRM Core When adding files into these directories it is advisable to follow similar patterns to that in CiviCRM Core e.g. BAO files should go in "CRM\_Myextension\BAO\", likewise with Form and Page. This ensures that for developers that seek to modify or improve the extension files can be found in standard locations.
e.g. BAO files should go in "CRM\_Myextension\BAO\", likewise with Form and Page. This ensures that for developers
that seek to modify or improve the extension files can be found in standard locations.
## The Big `E` ## The Big `E`
There are many times when you need to reference something from the There are many times when you need to reference something from the extension -- e.g. its name, its file-path, or its translated messages.
extension -- e.g. its name, its file-path, or its translated messages.
For example, this code displays a translated message (using the translation For example, this code displays a translated message (using the translation data for this extension):
data for this extension):
```php ```php
if ($welcoming) { if ($welcoming) {
...@@ -54,9 +40,7 @@ if ($welcoming) { ...@@ -54,9 +40,7 @@ if ($welcoming) {
Repeatedly entering the name of the extension is a bit tiresome. Repeatedly entering the name of the extension is a bit tiresome.
For code generated by `civix` v17.08.0+ (or suitably For code generated by `civix` v17.08.0+ (or suitably [upgraded](https://github.com/totten/civix/blob/master/UPGRADE.md)), `civix` includes the `E` helper which provides easier access:
[upgraded](https://github.com/totten/civix/blob/master/UPGRADE.md)), `civix`
includes the `E` helper which provides easier access:
```php ```php
use CRM_Mymodule_ExtensionUtil as E; use CRM_Mymodule_ExtensionUtil as E;
...@@ -68,9 +52,7 @@ if ($welcoming) { ...@@ -68,9 +52,7 @@ if ($welcoming) {
} }
``` ```
Note that `E` is an alias. It stands for "extension" -- as in "the current Note that `E` is an alias. It stands for "extension" -- as in "the current extension that I'm writing". It's a very thin class that provides small helpers for looking up your extension's resources, e.g.
extension that I'm writing". It's a very thin class that provides small
helpers for looking up your extension's resources, e.g.
* `E::ts($text)` -- Translate a string (using the extensions' translation file) * `E::ts($text)` -- Translate a string (using the extensions' translation file)
* `E::path($file)` -- Get the path to a resource file (within this extension) * `E::path($file)` -- Get the path to a resource file (within this extension)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment