Charles Tanton - backend Drupal engineer, based in Kommetjie

I'm a backend Drupal engineer with 20 years of experience. I'm currently contracted via Tag1 Consulting, working on a Drupal 11 and PHP 8+ system for a confidential Top 10 Global 500 company. I maintain Entity Inspector, a developer tool for inspecting raw entity data as JSON, and I'm a founding member of the Drupal Johannesburg User Group. This site is my home on the web, a place for my blog, my open-source work, and writing about backend engineering and where AI tools genuinely help in a developer's workflow.

Most recent work

Tag1 Consulting Drupal 10 & Drupal 11 backend work

Tag1 consulting

Since July 2019, I've been contracted by Tag1 Consulting, and am currently working as part of a team doing Drupal 10 & Drupal 11 frontend and backend work for one of their clients, a US based, Fortune 10 tech company (I'm not allowed to say who). We've been prototyping a number of potential new sites, and helping some of their in-house teams maintain and add features to existing sites.

Read more...

The Internet Advertising Bureau (IAB) UK Drupal 7 to Drupal 8 Migration

IABUK Drupal 8 website home page

I was contracted by LAB to manage the migration of content from the old IAB website (Drupal 7) to an under construction, Drupal 8, IAB UK website. I successfully set up and ran migrations for 16 Drupal 7 content types (including some with field collections), to some fairly complex, paragraph based, new Drupal 8 content types. This included document and image migration, as well as taxonomy migration. Some custom migration plugins had to be created to convert data from the old site into the correct format that the new site required.

Read more...

Most recent blog posts

A destruct() Flush Turns Thousands of Redundant Saves Into Hundreds

Submitted by charles on
Batching operations that trigger an same event subscriber can cause performance problems if that subscriber runs expensive operations. Here's how that happened, and the small change that fixed it without slowing the events down at all: accumulate the work as it comes in, and do it once at shutdown.

Using filter_var for boolean environment variables

Submitted by charles on

Someone on my team added the following setting to check whether an environment variable was true or false:

$settings['x_menu_admin_enable'] = strtolower(getenv('X_MENU_ADMIN_ENABLE')) === 'true' ? getenv('X_MENU_ADMIN_ENABLE') : FALSE;

I find that using PHPs filter_var makes this code a bit easier to parse and only calls getenv once:

Custom validation on a views field plugin options form

Submitted by charles on

When validating an options form for a views field plugin class that extends FieldPluginBase, you need to add a `validateOptionsForm()` function and use an array for getting the value although when setting the error you don't need to include 'options':

/**
 * {@inheritdoc}
 */
public function validateOptionsForm(&$form, FormStateInterface $form_state): void {