Instructions I will be creating a dedicated module using Drupal Console for this event subscriber. But feel free to use your own if you already have one! (don’t forget to backup) Access the drupal root folder in command line. Generate a new module:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
dakwamine@debian-drupal:/var/www/html/drupal$ drupal generate:module Enter the new module name: > Test Module Enter the module machine name [test_module]: > 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]: > no Define module as feature (yes/no) [no]: > Do you want to add a composer.json file to your module (yes/no) [yes]: > no Would you like to add module dependencies (yes/no) [no]: > Do you confirm generation? (yes/no) [yes]: > Generated or updated files Site path: /var/www/html/drupal 1 - modules/custom/test_module/test_module.info.yml |
Generate the event subscriber. We will subscribe to the kernel.request event: […]