Generate slug of a field. Uses camel case to create the slug from a string.

@param  string $slug
@param  array  $usedSlugs
@return string
333843
public static function generateSlug(string $slug, array $usedSlugs)
    {
        $slug = camel_case($slug);
        $count = 1;

        // adds a number in the slug string if the specific slug allready exists
        if (in_array($slug, $usedSlugs)) {
            while(true){
                $slug = camel_case($slug."_".$count);
                if (!in_array($slug, $usedSlugs)) {
                    return $slug;
                }
                $count++;
            }
        }

        return $slug;
    }
1061693
public function renderDropdownForSlugs( $slug ) {
		$select_name = 'slug';
		$select_id = $select_name;
		$redirect_url = get_admin_url( get_current_blog_id(), '/themes.php?page=' . $this::PAGE . '&slug=' );
		$html = '';

		$html .= "
	<script type='text/javascript'>
    // <![CDATA[
	jQuery.noConflict();
	jQuery(function ($) {
		$('#" . $select_id . "').change(function() {
		  window.location = '" . $redirect_url . "' + $(this).val();
		});
	});
	// ]]>
    </script>";

		$html .= '<select id="' . $select_id . '" name="' . $select_name . '">';
		foreach ( $this->supported as $key => $val ) {
			$html .= '<option value="' . $key . '"';
			if ( $key === $slug ) {
				$html .= ' selected="selected"';
			}
			if ( 'Web' === $val ) {
				$val = __( 'Web', 'pressbooks' );
			}
			$html .= '>' . $val . '</option>';
		}
		$html .= '</select>';

		return $html;
	}
1248601
public function template( string $slug, array $files = []) {
		$files = $files ?: (array) "{$slug}.php";
		
		return apply_filters("{$slug}_template", $this->locate( $files ) );
	}
1011040
public function prepareCanonicalURLForPersist($slug)
    {
        $baseURL = rtrim(config('app.url'), "/");

        if ($this->model->table == "posts") $type = "blog";


        // July 15, 2015: do *NOT* want type!

        //return $baseURL.'/'.$type.'/'.$slug;
        return $baseURL.'/'.$slug;
    }
898396
public static function load(string $slug)
    {
        $instance = new static();

        $instance->route = [];
        $instance->route['slug'] = $slug;
        $instance->route['groups'] = collect([]);

        return $instance;
    }
466326
public function updateBySlug(array $attributes, $slug)
    {
        $album = $this->findBySlug($slug);

        return $this->update($attributes, $album->id);
    }
14151
public function getApplicationComponentBySlug($slug)
    {
        $applicationComponents = $this->getApplicationComponents();
        foreach ($applicationComponents as $applicationComponent) {
            if ($applicationComponent->slug == $slug) {
                return $applicationComponent;
            }
        }

        return null;
    }
863600
public function findOneBySlug($slug)
    {
        // select
        $qb = $this->getQueryBuilder()
            ->select('p.id, t.title, t.description, t.metaTitle, t.metaDescription, t.metaTags, p.active');

        //join
        $qb->leftJoin('p.translations', 't');
        
        $qb->where('t.slug LIKE :slug')
           ->andWhere('p.active LIKE :active')
            ->setParameter('slug', '%'.$slug.'%')
            ->setParameter('active', true);

        return $qb->getQuery()->getSingleResult();
    }
935835
public function getIdForSlug($slug, User $user = null)
    {
        $query = Tag::where('slug', 'like', $slug);

        return $this->scopeVisibleTo($query, $user)->pluck('id');
    }
348469
public static function prefixSlug(string $slug) : string
    {
        if (substr($slug, 0, strlen(self::MODULE_PREFIX)) !== self::MODULE_PREFIX) {
            $slug = self::MODULE_PREFIX . $slug;
        }

        if (strlen($slug) > 20) {
            $slug = substr($slug, 0, 20);
        }

        $slug = strtolower($slug);

        return $slug;
    }
868590
public function generateFieldSlug($lang, $key, $id, $keys)
    {
        $count = 1;
        $found = true;
        $slug = str_slug($key, '_');

        $keysArray = array();
        foreach ($keys as $key){
            if($id != $key['id']) {
                $keysArray[] = $key['slug'];
            }
        }

        if(!in_array($slug, $keysArray) && !in_array($slug, $this->usedSlugs)) {
            return $slug;
        }else{
            while ($found){
                $newSlug = $slug.'_'.$count;
                if(!in_array($newSlug, $keysArray) && !in_array($newSlug, $this->usedSlugs)) {
                    $found = false;
                    $this->usedSlugs[] = $newSlug;
                    return $newSlug;
                }
                $count++;
            }
        }

        return $keysArray;
    }
156178
public static function createVirtualColumnsForSlug(string $postTypeSlug, $languageSlugs = [])
    {
        $languageSlugs = ($languageSlugs && !is_array($languageSlugs) ? explode(" ", $languageSlugs): $languageSlugs);
        $languageSlugs = ($languageSlugs ? $languageSlugs : Language::all()->pluck(['slug'])->toArray());

        $virtualColumns = [];
        foreach ($languageSlugs as $languageSlug){
            $virtualColumns[] = [
              "name" => $languageSlug,
              "type" => "string",
              "index" => true,
              "length" => 200,
            ];
        }
        AccioQuery::createVirtualColumns($postTypeSlug, "slug", $virtualColumns);
    }
5609
public function getDocumentBySlug($slug, $state = 'published')
    {
        if (!in_array($state, Document::$DOCUMENT_STATES, true)) {
            throw new \RuntimeException('Unsupported document state: ' . $state);
        }
        $path = '/' . $slug;

        return $this->repository->getContentRepository()->getDocumentByPath($this->repository, $path, $state);
    }
118325
public function deleteDocumentFolderBySlug($slug)
    {
        $path = '/' . $slug;
        $this->repository->getContentRepository()->deleteDocumentByPath($this->repository, $path);
        $this->repository->getContentRepository()->cleanPublishedDeletedDocuments();
    }
1199349
public function slugSafeString($handle, $maxlength = 128)
    {
        $handle = preg_replace('/[^\\p{L}\\p{Nd}\-_]+/u', ' ', $handle); // remove unneeded chars
        $handle = preg_replace('/[-\s]+/', '-', $handle); // convert spaces to hyphens
        return trim(Utf8::substr($handle, 0, $maxlength), '-'); // trim to first $max_length chars
    }
234825
public function getValuelistBySlug($slug)
    {
        $valuelists = $this->repository->valuelists;
        foreach ($valuelists as $valuelist) {
            if ($valuelist->slug == $slug) {
                return $valuelist;
            }
        }

        return null;
    }
609186
public function findOneBySlug($slug)
    {
        $query = $this->createValuedQueryBuilder('c')
            ->where('c.slug = :slug')
            ->setParameter('slug', $slug)
            ->getQuery();

        return $query->useResultCache(true, self::CACHE_TTL)->getSingleResult();
    }