Adding Simple Slug Generation doest work

In the tutorial this code doesnt work, can someone try help me, please?

public function beforeSave($event, $entity, $options)
{
if ($entity->isNew() && !$entity->slug) {
$sluggedTitle = Text::slug($entity->title);
// trim slug to maximum length defined in schema
$entity->slug = substr($sluggedTitle, 0, 191);
}
}

Do you get any error message? Does your code get into beforeSave? If yes, than try to debug what happens there.

Are you on CakePHP 3? Because your code is different from the cookbook.
https://book.cakephp.org/3.0/en/orm/behaviors.html#defining-event-listeners

Did you find a solution to the issue? I’m having the same issue with the example code provided in the tutorial.

What is the error you’re getting?
I accidentally broke my crystal ball yesterday and am still waiting for a new one from AliExpress…