How to change entity before it is created or updated.

0
(0)

Example How to change entity before it is created or updated using hook_entity_presave().

First example

function MODULE_entity_presave(EntityInterface $entity)
{
    if ($entity->getEntityTypeId() == 'node') {
        if ($entity->getType() == 'article') {
            $entity->set('title', $title);
        }
    }
}

Second example:

Similar Posts:

256

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Scroll to Top