As a fairly experienced Drupal 7 developer, I'm thrilled by all the new goodies in Drupal 8, but haven't quite figured out the relationship between entities and the new plugin system.

I've followed a number of tutorials on both topics, but haven't come across how they would fit together? Do they fit together?

I'd be very grateful for an explanation of how these two features coexist and inter-operate within the Drupal 8 ecosystem.



My specific use case

To clarify my question: I'm building a module that provides a method for the site owner to display alerts to their visitors. I've created a new custom Content Entity (cleverly called 'Alert') using Drupal Console and custom code.

I've also followed along with several tutorials that describe how to create a custom plugin type and found this idea exciting, but the gap in my understanding is this: when (or if) there would be a use case for combining a custom Content Entity with a custom plugin type. Does anyone have an example?


  • 1
    Examples are Menu Link Content and Block Content entities. Each instance in the database generates a plugin derivative so that it can be placed in the menu or block layout.
    – 4uk4
    Sep 29, 2017 at 11:47

1 Answer 1


I am not sure that I quite get your question but in Drupal 8 things like nodes, files and users are entities. They all inherit from ContentEntityBase. Plugins are a way to implement/extend Drupal functionality such as Views filters and Field widgets.

From the docs:

Entity API

Drupal 7 - entities were generic stdClass objects.

Drupal 8 - entities are now specifically typed objects, with each entity type defining a class that will be used for instances of the given entity.

Entity types in core comes in two variants.

Configuration Entity

Used by the Configuration System. Supports translations and can provide custom defaults for installations.

Content Entity

Consist of configurable and base fields, can have revisions and support translations.

Plugin API

Plugins are small pieces of functionality that are swappable. Plugins that perform similar functionality are of the same plugin type.

Drupal contains many different plugins, of different types. For example, 'Field widget' is a plugin type, and each different field widget type is a plugin. The admin user may select from the list of field widget plugins to set the widget that a field uses.

After author edit:

Your specific use case would call for a event subscriber approach in my opninion. More specifically an event subscribed to the KernelEvents::REQUEST event. You can check at every page request if there are open Alert entities for the user and display them accordingly.

Your question as to if there are use cases for combined entities and plugins I wouldn't know. I only ever created Views and Block plugins and never combined entities and plugins. Perhaps you could create a Block plugin and show your Alert entities in there?

  • Thanks for this. I've edited my question to (hopefully) make it more specific.
    – Beau
    Jun 28, 2017 at 19:26
  • You're welcome. Updated my answer, hope that helps.
    – mvdgun
    Jun 28, 2017 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.