/** * Generate content slug * * @param array $content object * @return string unique content slug */ private function generateContentSlug($content) { $slug = H5PCore::slugify($content['title']); $available = NULL; while (!$available) { if ($available === FALSE) { // If not available, add number suffix. $matches = array(); if (preg_match('/(.+-)([0-9]+)$/', $slug, $matches)) { $slug = $matches[1] . (intval($matches[2]) + 1); } else { $slug .= '-2'; } } $available = $this->h5pF->isContentSlugAvailable($slug); } return $slug; }