How to validate entity in different context?

by Ivan Jaros   Last Updated November 14, 2017 14:07 PM

I want to use the built-in validation mechanism to validate entity, just like it is done now, but in a different context.

For example I want to distinguish if published status is about to change or if only title is about to change(or with the workflow module if state is being changed from A to B, different validation should apply). Currently the \Drupal\Core\Entity\ContentEntityBase::validate does not provide any way to distinguish this context.

So I wonder if there is a way to do this Drupal-way or if I simply have to create some sort of wrapper and somehow map it to the typed data "schema"...which basically means I can do without constraints with simple exceptions, which I don't like.

Tags : 8 entities


Related Questions




How to create a custom template for entities?

Updated April 07, 2015 03:03 AM


Drupal 8 Custom Entities from a UI?

Updated July 14, 2015 15:03 PM