create custom module

理解

Examples module, Symfony, Controllers, and the Menu
Blocks, Configuration, and Forms
Configuration forms and management
Entities, Content Entities, and Configuration Entities
Entity queries , loading entities , editing fields
Services, dependency injection, and service containers

hooks

hook_help

修改输出帮助信息。

  1. module help
  2. 指定页面help

hook_toolbar

添加item到toolbar容器。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$items['commerce'] = array(
'#type' => 'toolbar_item',
'tab' => array(
'#type' => 'link',
'#title' => t('Shopping cart'),
'#url' => Url::fromRoute('cart'),
'#options' => array(
'attributes' => array(
'title' => t('Shopping cart'),
),
),
),
'tray' => array(
'#heading' => t('Shopping cart actions'),
'shopping_cart' => array(
'#theme' => 'item_list',
'#items' => array(/* An item list renderable array */),
),
),
'#weight' => 150,
);

hook_mail

根据参数构建mail内容

hook_mail_alter

根据条件不发送mail等