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

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 {

Get the full message from your Guzzle Response exception object

Submitted by charles on

I was trying to debug a Guzzle response error but the error message was fairly long and some crucial information about which specific API fields were unauthorized was missing. The Guzzle Client Exception object has some handy methods to allow reading the full message contents:

$exception->getResponse()->getBody()->getContents();