Snippets

To Terms

I often need to create taxonomy terms, checking if they exist first. This is a small function that handles that.
Tags

Drupal 8: Get widget state

When working with the hook altering the widget form, you often need to get the widget state to get the entities behind the form as well as additional information that is stored in the state. Here is the utility function for it.

Drupal 8: Custom AJAX Commands

When changing the ajax responses with hook_ajax_render_alter(), you may sometimes want to add a custom ajax command. Drupal 8 actually supports a plugin-like functionality for it. This functionality needs to be served by a custom module and consists of 2 files - a src/Ajax class and a javascript file implementing the command.
Tags

Drupal 8: Tempstore

Drupal 8 has a powerful mechanism to temporarily store data. Tempstore resembles storing data in session, and it also persists between the page reloads. There are two major types of storage that I ended up using: private tempstore and shared tempstore.