Oct 15, 2017

An Embarrassing Mistake: 'The "example" entity type does not exist'

Using the code from  Creating a configuration entity type in Drupal 8  to create a sample module for demonstrating use of configuration entities, I got the following log message when browsing to the path /admin/config/system/example

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "example" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 133 of /var/www/html/opti/core/lib/Drupal/Core/Entity/EntityTypeManager.php).

This is embarrassing, but I'm going to write it up anyway.

I had copied and pasted the code verbatim from the article into new files using the filenames and paths that were indicated. It should have worked!

It turns out I had forgotten one little thing: at the top of each of the php files, I had neglected to insert

<?php

What eventually tipped me off was that my text editor, Sublime Text, was not providing the syntax coloring that it normally did.

Laughing my ass off ...


Sources:

Creating a configuration entity type in Drupal 8
https://www.drupal.org/docs/8/api/configuration-api/creating-a-configuration-entity-type-in-drupal-8

Configuration Entities in Drupal 8
https://wunder.io/blog/configuration-entities-in-drupal-8/2014-07-14