Skip to content

Commit

Permalink
Merge pull request #558 from krispypen/fix/slugnotslugified
Browse files Browse the repository at this point in the history
[NodeBundle] Slugify the slug when saving the page
  • Loading branch information
Roderik van der Veer committed Jul 16, 2015
2 parents 0aa94c3 + 7070515 commit d3de632
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function prePersist(LifecycleEventArgs $args)

if ($entity instanceof NodeTranslation) {
$this->setSlugWhenEmpty($entity, $args->getEntityManager());
$this->ensureSlugIsSlugified($entity);
}
}

Expand All @@ -65,6 +66,7 @@ public function preUpdate(LifecycleEventArgs $args)

if ($entity instanceof NodeTranslation) {
$this->setSlugWhenEmpty($entity, $args->getEntityManager());
$this->ensureSlugIsSlugified($entity);
}
}

Expand All @@ -85,6 +87,10 @@ private function setSlugWhenEmpty(NodeTranslation $nodeTranslation, EntityManage
}
}

private function ensureSlugIsSlugified(NodeTranslation $nodeTranslation) {
$nodeTranslation->setSlug($this->slugifier->slugify($nodeTranslation->getSlug()));
}


/**
* onFlush doctrine event - collect all nodetranslations in scheduled entity updates here
Expand Down

0 comments on commit d3de632

Please sign in to comment.