]> BookStack Code Mirror - bookstack/blobdiff - app/Repos/EntityRepo.php
Merge branch 'master' into translations
[bookstack] / app / Repos / EntityRepo.php
index 42b0b6b7bef89aecfbecc0f914fde8266ec7eb5e..7ecfb758c9e31364414987cc1121fa1df18f377d 100644 (file)
@@ -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;
+    }
+
 }