Ditch copyright stuff, keep adding tips
This commit is contained in:
parent
595fc9a347
commit
6e2165d8bc
1 changed files with 65 additions and 66 deletions
|
@ -328,6 +328,18 @@ Act Two
|
|||
|
||||
Note: Build on or with some major —and with luck join a community of people invested in a part of Drupal and willing to share passion and knowledge.
|
||||
|
||||
---
|
||||
|
||||
### Look for opportunities to plug in
|
||||
|
||||
No, literally, look for plugins.
|
||||
|
||||
In `src/Plugin` of whatever modules you are operating in the vicinity of.
|
||||
|
||||
|
||||
Note: Doing your own module by extending an existing plugin or copying and modifying an existing plugin is probably the highest impact to effort ratio.
|
||||
|
||||
|
||||
---
|
||||
|
||||
#### Example: BEF Links Filter
|
||||
|
@ -336,6 +348,8 @@ Note: Build on or with some major —and with luck join a community of people in
|
|||
|
||||
Search API's friends include Facets and Better Exposed Filters
|
||||
|
||||
BEF Links Filter is a `better_exposed_filters` plugin in about 250 lines of code altogether.
|
||||
|
||||
Note: By extending BEF Links module, we were able to get a lot of power— with a much better user experience, thanks to our ~250 lines of code altogether.
|
||||
|
||||
----
|
||||
|
@ -400,19 +414,6 @@ Note: The main thing to note there is `parent::` which you will use when extendi
|
|||
|
||||
---
|
||||
|
||||
#### Look for opportunities to plug in
|
||||
|
||||
No, literally, look for plugins.
|
||||
|
||||
In `src/Plugin` of whatever modules you are operating in the vicinity of.
|
||||
|
||||
BEF Links Filter is a `better_exposed_filters` plugin in about 250 lines of code altogether.
|
||||
|
||||
|
||||
Note: Doing your own module by extending an existing plugin or copying and modifying an existing plugin is probably the highest impact to effort ratio.
|
||||
|
||||
---
|
||||
|
||||
Act Three
|
||||
|
||||
### How To Figure Out How To Make a Module
|
||||
|
@ -468,7 +469,7 @@ Note: Grep. Even when i am fully using an IDE for everything else, i grep in th
|
|||
* Route subscriber
|
||||
* Event subscriber
|
||||
|
||||
Note: The three main ways to mess with Drupal 8 and 9: hooks, plugins, and services, with a couple examples in each. Both examples of what technically to do and how to do general things. For example: Doing something with a form? You want hook_form_alter() or one of its variants.
|
||||
Note: The three main ways to mess with modern: hooks, plugins, and services, with a couple examples in each. Both examples of what technically to do and how to do general things. For example: Doing something with a form? You want hook_form_alter() or one of its variants.
|
||||
|
||||
---
|
||||
|
||||
|
@ -513,54 +514,6 @@ File issues for your own modules.
|
|||
|
||||
Note: It helps you think through what you are planning to do, it makes features and bugs more discoverable by other people, if you do not get to it right away there is a chance someone else will (in a way that they coordinate with you!), and you (and anyone else who helps) get Drupal.org issue credit for that (you get no credit for contributing the actual module).
|
||||
|
||||
---
|
||||
|
||||
Be willing to commit based on your own opinion, don’t let issues languish waiting for the community to test, if you feel it’s good and you gave a bit of time (or feel it doesn’t need it) be willing to commit it on your own accord (also valid for “maintainer adjusted on commit”)
|
||||
— cmlara
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
```yaml
|
||||
name: "Project Copyright"
|
||||
type: module
|
||||
description: "Generate a block with the copyright leyend."
|
||||
core_version_requirement: ^8 || ^9 || ^10 || ^11 || ^12
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace Drupal\copyright\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
|
||||
/**
|
||||
* Provides a block with the copyright legend.
|
||||
*
|
||||
* @Block(
|
||||
* id = "copyright_block",
|
||||
* admin_label = @Translation("Copyright"),
|
||||
* )
|
||||
*/
|
||||
class Copyright extends BlockBase {
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function build() {
|
||||
return [
|
||||
'#markup' => $this->t('Copyright © @year All rights reserved', ['@year' => date('Y')]),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
@ -580,7 +533,7 @@ To implement a hook, take the 'hook' part off the hook name and replace it with
|
|||
|
||||
## 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.
|
||||
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/11.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/
|
||||
|
||||
|
@ -588,8 +541,8 @@ https://api.drupal.org/api/drupal/core%21core.api.php/group/extending/
|
|||
|
||||
### Key hooks
|
||||
|
||||
* [hook form_alter](https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21form.api.php/function/hook_form_alter/9.0.x )
|
||||
* [hook_entity_extra_field_info](https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook_entity_extra_field_info/9.0.x ) + a 'field' site builders can use in entity view modes, such as to combine entity data and format it for display. Or you can replace those three hooks with one plugin by using the [Extra field module](https://www.drupal.org/project/extra_field )
|
||||
* [hook form_alter](https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21form.api.php/function/hook_form_alter/11.0.x)
|
||||
* [hook_entity_extra_field_info](https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook_entity_extra_field_info/11.0.x ) + a 'field' site builders can use in entity view modes, such as to combine entity data and format it for display. Or you can replace those three hooks with one plugin by using the [Extra field module](https://www.drupal.org/project/extra_field )
|
||||
|
||||
### All the hooks
|
||||
|
||||
|
@ -604,7 +557,25 @@ Note: A note on all these links: I've linked to the Drupal 9.0 version. These h
|
|||
|
||||
### Don't bother to support older versions
|
||||
|
||||
Note: And i'm not talking about Drupal 7, 6, 5, or 4.7. Don't bother with Drupal 10 if you want to use the new cool object-oriented style hooks.
|
||||
In your `*.info.yml`
|
||||
|
||||
```yaml
|
||||
core_version_requirement: ^10.2 || ^11
|
||||
```
|
||||
|
||||
Note: And i'm not talking about Drupal 7, 6, 5, or 4.7. Don't bother with Drupal 10 if you want to use the new cool object-oriented style hooks that came in Drupal 11.1. Some good stuff came in Drupal 10.2, so this exact line is common right now, and if you are making a new module you would not be excluding anybody really to start with this.
|
||||
|
||||
----
|
||||
|
||||
### Bonus bonus tip
|
||||
|
||||
#### Read Drupal Core Release Notes
|
||||
|
||||
[drupal.org/project/drupal/releases](https://www.drupal.org/project/drupal/releases)
|
||||
|
||||
"This is a **a feature minor release of Drupal 11**" are the sorts of words you are looking for.
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
@ -768,6 +739,34 @@ Note: Don't think about this too much when starting development; 'Actively maint
|
|||
|
||||
There is another option there, 'Unsupported', but please do not select that after contributing a module unless after starting development you find another module that does what you were trying to do better.
|
||||
|
||||
|
||||
---
|
||||
|
||||
#### commit based on your own opinion
|
||||
— cmlara
|
||||
|
||||
Note: Be willing to commit based on your own opinion, don’t let issues languish waiting for the community to test, if you feel it’s good and you gave a bit of time (or feel it doesn’t need it) be willing to commit it on your own accord (also valid for “maintainer adjusted on commit”)
|
||||
|
||||
From
|
||||
|
||||
---
|
||||
|
||||
----
|
||||
|
||||
#### Write and/or generate release notes
|
||||
|
||||
[drupal-mrn.dev](https://drupal-mrn.dev/)
|
||||
|
||||
Note: This is great, i wrote something similar for Drutopia but we were on GitLab which accepted Markdown at the time, so i had actually been generating markdown. Which reminds me there is a tool from that era i do use all the time…
|
||||
|
||||
---
|
||||
|
||||
#### Have a README.md file
|
||||
|
||||
[gitlab.com/drutopia/writeme](https://gitlab.com/drutopia/writeme) will generate a simple README from your `composer.json`.
|
||||
|
||||
Note: This way you add your description, issue queue link, funding source, etc to `composer.json` and add them to your README for free.
|
||||
|
||||
---
|
||||
|
||||

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