Example #1
0
 protected function preSave(Sport $sport)
 {
     $slugifier = new Slugify();
     // set slug
     if (Text::create($sport->getSlug())->isEmpty()) {
         $sport->setSlug($slugifier->slugify($sport->getTitle()));
     }
     // set object slug
     if (Text::create($sport->getObjectSlug())->isEmpty() && !Text::create($sport->getObjectLabel())->isEmpty()) {
         $sport->setObjectSlug($slugifier->slugify($sport->getObjectLabel()));
     }
     // set skill slug
     if (Text::create($sport->getSkillSlug())->isEmpty()) {
         $sport->setSkillSlug($slugifier->slugify($sport->getSkillLabel()));
     }
     // set group slug
     if (Text::create($sport->getGroupSlug())->isEmpty()) {
         $sport->setGroupSlug($slugifier->slugify($sport->getGroupLabel()));
     }
 }