5 Videos on Saving Custom Data to a Drupal 8 Database

In Drupal 7, when you wanted to save arbitrary data to the database you would use variable_set() and variable_get(). The problem with this system was that sometimes you wanted to store this same data across multiple instances of your site - like the name of your site - and other times you wanted different values for each instance. The solution in Drupal 8 is to split the two use cases into separate APIs.

This week we look at these two APIs - the State API and Configuration APIs - as we continue the process of upgrading our Drupal 7 module.

(FREE!) A comparison of the State API and the Configuration API and how they replace variable_get() - 2:37

In Drupal 8, variable_set() and variable_get() are no more. Instead, their purpose has been replaced by two separate storage APIs. In this video we go over the role of these two APIs and when you might want to use each.

How to use the State API to store arbitrary values - 2:07

In this video we cover the specific syntax of using the State API before we dive in and start using it.

How to replace variable_get() with a State API call - 0:55

Upgrading a module is often just hitting a series of errors and fixing them. In this video we tackle our first error by replacing out a variable_get() call with some new and shiny State API code.

How to replace drupal_get_title() with a call to the "title resolver" service - 2:40

Here we figure out how to get the title of the current page. It’s not as simple as it used to be, but we break down the process into understandable pieces.

How to replace variable_set() with a State API call - 1:23

We’ve already covered how to upgrade variable_get() calls, and in this video we complete the circle by using the State API to set a value.

Have a great week!

- Chris Shattuck

Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:


Loading...
Contact us

Below are the supported keyboard shortcuts for our video player.

space
Start / stop video
shift
Go to next video
shift
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
1...9
Jump to a percentage (2 is 20%, for example)
f
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
$29
1 month
$156
6 months
10% off
$276
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
user
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.