Recent updates: Drupal 8.5, Automated Testing videos and more

Image

Here are some of the updates we've made to tutorials this past quarter at Drupalize.Me!

8.5 updates

In March, we scoured the change records for 8.5 to see which tutorials needed to be updated. Here are the updates we made:

Added a section on incremental migrations (change record).

More information

The Migrate Drupal UI module allows you to execute a migration from older versions of Drupal to the latest version of Drupal. In this tutorial we'll:

  • Run a full Drupal 6 to latest-Drupal (Drupal 8 or 9) Migration from the UI
  • Explore the user interface as it exists
  • Understand how we can deal with the output from our migration

Added a link to the new format_date Migrate process plugin (change record).

Categories
Drupal 8, 9, and 10
More information

Process plugins manipulate data during the transform phase of the ETL process while the data is being moved from the source to the destination. Drupal core provides a handful of common process plugins that can be used to perform the majority of data transformation tasks. If you need some functionality beyond what is already provided you can write your own custom process plugins.

In this tutorial we'll:

  • Examine the role that process plugins fullfil
  • Understand the processing pipeline
  • List the existing process plugins in Drupal core and what each one does
  • Better understand when you might need to write your own process plugin

By the end of this tutorial you should be able to explain what process plugins do, and understand how you'll make use of them in your own migration.

Edited example and explanation of source plugin with new requirement to show module responsible for annotation (change records 1 and 2).

Categories
Drupal 8, 9, and 10
More information

This tutorial covers writing a custom source plugin that imports data from a MySQL database into Drupal nodes. After completing this tutorial you should understand how to write your own custom source plugin that can:

  • Extract data from an SQL source
  • Describe the various fields in the source data to the Migrate API for mapping
  • Provide unique IDs for each row of imported data

By the end of this tutorial you should be able write a custom source plugin that uses an SQL data store as well as have a foundation for writing source plugins that extract data from any source that PHP can read.

More information

As part of creating a custom Drupal-to-Drupal migration we want to limit the set of users that are migrated from our source site into our destination Drupal site. In this tutorial we'll:

  • Extend the existing source plugin
  • Alter the query that's used to select users from our source site
  • Update our user migration to use the new source plugin

By the end of this tutorial you should be able to override the core source plugins used when migrating from prior versions of Drupal in order to gain more control over exactly what is migrated.

Renamed migration_templates directory to migrations (change record).

More information

To follow along with the rest of the migration tutorials you'll want to make sure you understand the following concepts and terms as they relate to Drupal migrations.

In this tutorial, we'll take look at the basic components of a migration and familiarize ourselves with some of the concepts and terminology needed to understand how the system works. We'll cover:

  • What is a migration?
  • Migration templates
  • The extract, transform, load process
  • Destinations and sources
  • Additional Drupalisms

By the end of this tutorial you should be able to identify the various components that a migration is composed of, and explain at a basic level what each is responsible for.

Replaced use of drupal_set_message() with Messenger service (change record).

More information

In this tutorial, you'll learn how to add a property to a configuration entity in Drupal. Previously, we created a configuration entity called Transcode Profile and learned about the files and code that compose a configuration entity. Now, we'll add a new property called codec to this configuration entity and learn some new concepts in the process.

In order to add this new property to our custom configuration entity, we'll need to update our schema file, configuration entity forms, the entity list builder class, and add getter and setter methods to our main TranscodeProfile class.

Categories
Drupal 8, 9, and 10
More information

In this tutorial we’re going to walk through the process of creating a custom configuration entity in Drupal in a custom module. We'll be using Drupal Console's generate:entity:config command to create and update the files in our Transcode Profile example module. After Drupal Console has generated and updated the files for our configuration entity, we'll walk through each file and see how they define data structure, metadata, an administrative interface, and menu links for a configuration entity in Drupal.

By the end of this tutorial, you should be able to:

  • Use Drupal Console to generate a configuration entity
  • Identify files associated with a configuration entity and summarize the purpose and function of the code inside each file
  • Find other examples of configuration entities in Drupal core
Categories
Drupal 8, 9, and 10
More information

Modules can declare their interest in being notified when a specific event, or events, are triggered by implementing an event subscriber. This can be used to react to events in order to add your own logic, or to alter Drupal's existing functionality.

In this tutorial we'll cover how to subscribe to an event from your own module. After completing this tutorial you should be able to subscribe to any event and ensure that your custom code is executed when the specific event is triggered.

More information

A common use of Ajax is to alter a form by adding, removing, or updating parts of the form in response to actions taken by the user. The resulting altered form is still eventually submitted with a traditional HTTP POST request. For example, one might update the options available in a city dropdown field after someone has chosen a value in the country dropdown, or add an additional textfield for collecting a person's name when the user clicks an "Add another person" button.

In this tutorial we'll:

  • Understand why certain types of modifications to a form require the use of Ajax
  • Use #ajax in conjunction with a <select> field to demonstrate how to update a form with Ajax
  • Learn about responding to user interaction with #ajax

By the end of this tutorial you should be able to use the #ajax attribute on any form element to respond to user actions and update the form displayed to the user with new content and options.

More information

Each form is defined by a controller, a class that implements the \Drupal\Core\Form\FormInterface. Form controllers declare the unique ID of the form, the $form array that describes the content of the form, how to validate the form, and what to do with the data collected.

In this tutorial we'll:

  • Define a new form controller class
  • Implement the required methods to describe a form
  • Add a route that can be used to access our form

By the end of this tutorial you should be able to define a form that adheres to the FormInterface requirements and know where to find more information about how to further customize your form controller.

More information

Sometimes you need to add additional processing of input to forms where your module doesn't implement the form controller. In order to do this you can use the #submit property of the root level $form element, or of a specific button on a form, to add one or more callbacks. These functions, or methods, will be automatically called when the Form API is processing a submitted form and give your custom code an opportunity to do whatever it needs to do.

In this tutorial we'll:

  • Look at alternative ways to affect the submission handling of a form like #submit callbacks

By the end of this tutorial you should know how to add a #submit callback to an entire form, or a specific button in a form.

More information

When you create a custom form for Drupal and your module defines the form controller, the best way to handle processing of submitted data is via the submitForm() method of your controller. This method is called automatically by the Form API during the process of handling a user-submitted form. It can be used to save incoming data to the database, trigger a workflow based on user input, and instruct the Form API where to send the user after form processing has completed.

In this tutorial we'll:

  • Demonstrate how to add a submitForm() method to a form controller class
  • Access the value(s) of form input elements via the $form_state object
  • Set a redirect after performing processing in a form submission handler

By the end of this tutorial you should know how to access the values of a submitted form, and how to write custom processing code inside of the submitForm() method of a form controller.

Categories
Drupal 8, 9, and 10
More information

As a module developer you should define and invoke new hooks in your module in order to allow other developers -- or even future you -- to extend your module's functionality without hacking your module's code. This requires:

  • Creating a new, unique, name for your hook
  • Providing documentation for your hook
  • Invoking the hook at critical points in your code

By the end of this tutorial you should have a better idea of when to define a new hook and know how to invoke a hook from your code.

Updated links to PHPUnit docs to PHPUnit 6 (change record).

More information

In this tutorial, we will look at the various types of tests and testing frameworks included in Drupal core. We'll also provide an overview of how the different frameworks operate and the types of situations where each of the different frameworks is useful.

New videos for Automated Testing tutorials

Speaking of tutorials on automated testing, this month we've published 6 videos and added them to Install Drupal Development Requirements with Composer, Run Drupal Tests with Simpletest UI and run-tests.sh, Run Drupal Tests with PHPUnit, Set up a Functional Test, Implement a Functional Test, and Implement a Unit Test in Drupal.

Walk through all the tutorials in this series here:

Always updating

We're always listening to your feedback and have made numerous other corrections, clarifications, and updates to many tutorials on the site. In particular, we've made updates to several tutorials in our Docker series. Thank you for letting us know whether or not a tutorial was helpful and why. We really appreciate that input.

Next up

Right now we're reviewing major updates to our Configuration Management series and adding new and revised content related to deployment workflows. Those will be published in July. Also in progress are new tutorials on Content Moderation -- the first batch should be ready in August.

What content are you looking for?

What Drupal tutorials are you missing in your life? Let us know via support or in the comments below!

Comments

Right now we already use lando (https://docs.devwithlando.io/) for docker-based drupal development. It works quite good. We can use it with xdebug even for drush commands and so on ... perhaps this is an interesting topic for other users too.

To start with You got an awesome blog. I will be keen on more comparative points. I see you got extremely exceptionally valuable themes, GPS Tracker

Add new comment

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <code class> <ul type> <ol start type> <li> <dl> <dt> <dd><h3 id> <p>
  • Lines and paragraphs break automatically.

About us

Drupalize.Me is the best resource for learning Drupal online. We have an extensive library covering multiple versions of Drupal and we are the most accurate and up-to-date Drupal resource. Learn more