/** * Uses the configuration settings to generate a slug for the given $entity. * @param Entity $entity * @return string slug */ private function _generateSlug(Entity $entity) { $config = $this->config(); # load the config built by the instantiated behavior if ($entity->get($config['field']) && !$config['overwrite']) { # if already set, and !overwrite return $entity->get($config['field']); # return existing } $value = Slug::generate($config['pattern'], $entity, $config['replacement']); return $value; # return the slug }
public function testNonStandardReplacement() { $slug = Slug::generate('dr who', [], '.'); $this->assertEquals('dr.who', $slug); }