- From the root of your Drupal site, generate a module with the generate:module command and follow the interactive process. Use the defaults prompted as well as giving it a module name:
$ drupal generate:module
// Welcome to the Drupal module generator
Enter the new module name:
> Content Entity Provider
Enter the module machine name [content_entity_provider]:
>
Enter the module Path [/modules/custom]:
>
Enter module description [My Awesome Module]:
>
Enter package name [Custom]:
>
Enter Drupal Core version [8.x]:
>
Do you want to generate a .module file (yes/no) [yes]:
>
Define module as feature (yes/no) [no]:
>
Do you want to add a composer.json file to your module (yes/no) [yes]:
>
Would you like to add module dependencies (yes/no) [no]:
>
Do you want to generate a unit test class (yes/no) [yes]:
>
Do you want to generate a themeable template (yes/no) [yes]:
>
Do you confirm generation? (yes/no) [yes]:
>
Generated or updated files
1 - modules/custom/content_entity_provider/content_entity_provider.info.yml
2 - modules/custom/content_entity_provider/content_entity_provider.module
3 - modules/custom/content_entity_provider/composer.json
4 - modules/custom/content_entity_provider/tests/src/Functional/LoadTest.php
5 - modules/custom/content_entity_provider/content_entity_provider.module
6 - modules/custom/content_entity_provider/templates/content-entity-provider.html.twig
- Next, we will generate our content entity. Specify the module name that will provide the entity:
$ drupal generate:entity:content
Enter the module name [devel]:
> content_entity_provider
Enter the class of your new content entity [DefaultEntity]:
> CustomContentEntity
Enter the machine name of your new content entity [custom_content_entity]:
>
Enter the label of your new content entity [Custom content entity]:
>
Enter the base-path for the content entity routes [/admin/structure]:
>
Do you want this (content) entity to have bundles (yes/no) [no]:
>
Is your entity translatable (yes/no) [yes]:
>
Is your entity revisionable (yes/no) [yes]:
>
Generated or updated files
1 - modules/custom/content_entity_provider/content_entity_provider.permissions.yml
2 - modules/custom/content_entity_provider/content_entity_provider.links.menu.yml
3 - modules/custom/content_entity_provider/content_entity_provider.links.task.yml
4 - modules/custom/content_entity_provider/content_entity_provider.links.action.yml
5 - modules/custom/content_entity_provider/src/CustomContentEntityAccessControlHandler.php
6 - modules/custom/content_entity_provider/src/CustomContentEntityTranslationHandler.php
7 - modules/custom/content_entity_provider/src/Entity/CustomContentEntityInterface.php
8 - modules/custom/content_entity_provider/src/Entity/CustomContentEntity.php
9 - modules/custom/content_entity_provider/src/CustomContentEntityHtmlRouteProvider.php
10 - modules/custom/content_entity_provider/src/Entity/CustomContentEntityViewsData.php
11 - modules/custom/content_entity_provider/src/CustomContentEntityListBuilder.php
12 - modules/custom/content_entity_provider/src/Form/CustomContentEntitySettingsForm.php
13 - modules/custom/content_entity_provider/src/Form/CustomContentEntityForm.php
14 - modules/custom/content_entity_provider/src/Form/CustomContentEntityDeleteForm.php
15 - modules/custom/content_entity_provider/custom_content_entity.page.inc
16 - modules/custom/content_entity_provider/templates/custom_content_entity.html.twig
17 - modules/custom/content_entity_provider/src/Form/CustomContentEntityRevisionDeleteForm.php
18 - modules/custom/content_entity_provider/src/Form/CustomContentEntityRevisionRevertTranslationForm.php
19 - modules/custom/content_entity_provider/src/Form/CustomContentEntityRevisionRevertForm.php
20 - modules/custom/content_entity_provider/src/CustomContentEntityStorage.php
21 - modules/custom/content_entity_provider/src/CustomContentEntityStorageInterface.php
22 - modules/custom/content_entity_provider/src/Controller/CustomContentEntityController.php
- Install your module using Drupal Console:
$ drupal module:install content_entity_provider
Installing module(s) "content_entity_provider"
[OK] The following module(s) were installed successfully: "content_entity_provider"
// cache:rebuild
Rebuilding cache(s), wait a moment please.
[OK] Done clearing cache(s).
- View Structure and find your Custom content entity settings: