/** * Fired just before saving the entry. * * @param EntryInterface|PostInterface $entry */ public function creating(EntryInterface $entry) { if (!$entry->getStrId()) { $entry->setAttribute('str_id', str_random()); } parent::creating($entry); }