Drupal 8

Hook form with build validate and submit Arrea Systems

Context

EK application has a module that store personal documents for user. When user account is deleted, those documents may be transferred to another account.

To achieve that, we need to alter the user account cancel form when building the form, validating and submitting it.

Let's review the 3 steps.

 

BUILD

The form before altering it looks like this

cancel user account before hook

We need to add a field to select another user account to which the document of the canceled account will be moved to.

To achieve that we Implements hook_form_alter() in MyModule.module:

Queue email

 

When sending email from your application, using queuing process can reduce the application response time and increase speed.

By sending the message to queue instead of sending directly at the end of server response, you may achieve better user experience. Once messages are in queue, you just need a scheduled cron task to initiate scheduled email sending.

How ?

Queuing is simple in Drupal 8

Let's imagine you have a module that currently send an email using mail plugin to multiple users:


foreach (User::loadMultiple($users) as $account) {
    \Drupal::service('plugin.manager.mail')->mail(
            'my_module,
            'my_key',
            $account->getEmail(),
            $account->getPreferredLangcode(),
            $params,
            $from->mail,
            TRUE
         );
}

 

To direct message to queue instead, you can replace with queue service:

EK Currencies | manually add new currency DA
Custom view video tutorial: sales per project category Arrea Systems
This video tutorial was made for our customer in order to demonstrate how to build a custom view to extract the data they need: A view to extract sales data per project where each project is classified into a category.