You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[AsEntityListener]
class ConferenceEntityListener
{
private$slugger;
publicfunction__construct(SluggerInterface$slugger)
{
$this->slugger = $slugger;
}
// explicit style, all possible arguments listed
#[OnEvent(event: Events::preUpdate, entity: Conference::class, lazy: true|false, entityManager: 'foo_em')]
publicfunctionprePersist(Conference$conference, LifecycleEventArgs$event)
{
$conference->computeSlug($this->slugger);
}
// compact style: event/method and entity are inferred from the signature, no attribute is needed on the methodpublicfunctionpreUpdate(Conference$conference, LifecycleEventArgs$event)
{
$conference->computeSlug($this->slugger);
}
}
Thanks to PHP 8 and autoconfiguration, we should be able to replace such configs by attributes:
(example from the-fast-track)
$container->registerAttributeForAutoconfiguration()
might help.Help wanted!
The text was updated successfully, but these errors were encountered: