Steal, steal, steal from my old presentations
This commit is contained in:
parent
6ce773f7c5
commit
199da5ba07
2 changed files with 91 additions and 1 deletions
|
@ -48,3 +48,67 @@ contributed-module-ideas
|
|||
|
||||
You are having an effect on the world. Or at least your local site.
|
||||
|
||||
|
||||
## Getting help
|
||||
|
||||
The Internet.
|
||||
|
||||
It's good.
|
||||
|
||||
|
||||
### Tip: Looking up Hooks
|
||||
|
||||
We can look up hook definitions and their function signatures the same way we look up Drupal functions, at api.drupal.org:
|
||||
|
||||
api.drupal.org/hook_help
|
||||
|
||||
api.drupal.org
|
||||
drupalcontrib.org
|
||||
|
||||
|
||||
### Examples project
|
||||
|
||||
[drupal.org/project/examples](https://www.drupal.org/project/examples)
|
||||
|
||||
|
||||
Tip: grep
|
||||
|
||||
grep -nHR module_implements_alter .
|
||||
|
||||
./includes/module.inc:646: if ($hook != 'module_implements_alter') {
|
||||
|
||||
./modules/system/system.api.php:1775:function hook_module_implements_alter(&$implementations, $hook) {
|
||||
|
||||
|
||||
### Tip: Clear Caches
|
||||
|
||||
If something you do has no effect...
|
||||
|
||||
`drush cr`
|
||||
|
||||
|
||||
## Coding Standards
|
||||
|
||||
|
||||
drupal.org/coding-standards
|
||||
|
||||
Automated Nagging
|
||||
|
||||
drupal.org/project/coder
|
||||
|
||||
Automatic Adherence
|
||||
|
||||
drupal.org/project/grammar_parser
|
||||
(obsolete?)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
The most important thing about this code is that i stole it.
|
||||
|
||||
I looked at how another module did it.
|
||||
|
||||
Implementing hooks is simply following patterns, it would be crazy not to copy.
|
||||
|
|
|
@ -112,6 +112,14 @@ function frankenstein_form_node_frankenstein_form_alter(&$form, \Drupal\Core\For
|
|||
}
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
There we go, there's a module! I think we're done here. Anyone have any ideas for the next 40 minutes?
|
||||
|
||||
.info files are not PHP. They cleverly indicate this by not starting with <?php
|
||||
|
||||
.module files are PHP...
|
||||
{{% /note %}}
|
||||
|
||||
---
|
||||
|
||||
### Where to put these files
|
||||
|
@ -512,10 +520,18 @@ Every contributed module can provide hooks, too.
|
|||
|
||||
---
|
||||
|
||||
Hooks work by naming convention.
|
||||
|
||||
To implement a hook, take the 'hook' part off the hook name and replace it with your module's (machine) name.
|
||||
|
||||
---
|
||||
|
||||
## Resources
|
||||
|
||||
Most of these links go to a page on [Drupal's API reference which is also a great place to go for an overview](https://api.drupal.org/api/drupal/9.0.x) of what tools are available to you as you pick through the pieces Drupal offers and assemble your module.
|
||||
|
||||
https://api.drupal.org/api/drupal/core%21core.api.php/group/extending/
|
||||
|
||||
---
|
||||
|
||||
### Key hooks
|
||||
|
@ -685,6 +701,17 @@ Your project root `composer.json`:
|
|||
|
||||
---
|
||||
|
||||
### Examples for developers project
|
||||
|
||||
[drupal.org/project/examples](https://www.drupal.org/project/examples)
|
||||
|
||||
{{% note %}}
|
||||
It's like it was written just for you.
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
Drupal.org/planet to keep up to date with what is going on in the Drupal world.
|
||||
|
@ -700,7 +727,6 @@ UnderstandDrupal.com shameless plug
|
|||
{{% note %}}
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue