X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ac80723058ab4c86e6bf024e0c75b60ab6c59624..refs/pull/236/head:/app/Repos/EntityRepo.php diff --git a/app/Repos/EntityRepo.php b/app/Repos/EntityRepo.php index 42b0b6b7b..7ecfb758c 100644 --- a/app/Repos/EntityRepo.php +++ b/app/Repos/EntityRepo.php @@ -269,6 +269,19 @@ class EntityRepo $this->permissionService->buildJointPermissionsForEntities($collection); } + /** + * Format a name as a url slug. + * @param $name + * @return string + */ + protected function nameToSlug($name) + { + $slug = str_replace(' ', '-', strtolower($name)); + $slug = preg_replace('/[\+\/\\\?\@\}\{\.\,\=\[\]\#\&\!\*\'\;\:\$\%]/', '', $slug); + if ($slug === "") $slug = substr(md5(rand(1, 500)), 0, 5); + return $slug; + } + }