Prefixes module post type slug if needed
@param  string $slug
@return string
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;
    }
746374
static function get_module_unique_affix( $slug, $is_plugin = true ) {
            $affix = $slug;

            if ( ! $is_plugin ) {
                $affix .= '-' . WP_FS__MODULE_TYPE_THEME;
            }

            return $affix;
        }
695330
public function findBySlug($slug)
    {
        return $this->plugger
            ->setModel($this)
            ->setAdapter(Post::class)
            ->plugIn(get_page_by_path($slug, OBJECT, $this->getSlug()))
            ->getConnected()
            ->first();
    }
201026
public static function createRouteFile(string $slug, $controller = 'PostController')
    {
        $stub =  File::get(stubPath('PostType'));
        $route = str_replace('DummySlug', cleanPostTypeSlug($slug), $stub);
        $route = str_replace('DummyController', $controller, $route);
        $bytes_written = File::put(base_path().'/routes/'.$slug.'.php', $route);
        if ($bytes_written === false) {
            die("Error writing to new route file");
        }
        return $route;
    }
1162590
private function createUniqueNumericSlug($slug)
    {
        if ($this->isNumericSlug($slug)) {
            // Extract last number and increment it
            $number = substr($slug, -1, 1);
            $number++;

            // Replace with new number
            $string = substr($slug, 0, strlen($slug) - 1) . $number;

            return $string;
        } else {
            return $slug;
        }
    }
760638
protected function checkValidSlug($slug)
    {
        if (preg_match_all('#^([a-z,A-Z,0-9,\-,_]*)(.+)?$#', $slug, $matches)
            && (strlen($matches[2][0]) > 0)
        ) {
            throw new \RuntimeException(
                sprintf(
                    'Error: prefix "%s" is invalid. It must only contain letters, numbers, underscores and hyphens. ' .
                    'Found problem near: "%s"',
                    $slug,
                    $matches[2][0]
                )
            );
        }
    }
1151929
private function sanitize_slug( &$slug ) {
		$slug = sanitize_key( $slug );
		if ( '' === $slug ) {
			$slug = count( $this->child );
		}
	}
383816
public function block($slug)
    {
        $block = $this->findABlock($slug);

        if (!$block) {
            $this->update([
                'blocks' => json_encode(array_merge($this->blocks, [ $slug => '' ]))
            ]);
        }

        return $block;
    }
446853
public function slug(string $slug): SectionTwigExtension
    {
        $this->throwNotFound = true;
        $this->options[ReadOptions::SLUG] = $slug;

        return $this;
    }
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();
    }
14151
public function getApplicationComponentBySlug($slug)
    {
        $applicationComponents = $this->getApplicationComponents();
        foreach ($applicationComponents as $applicationComponent) {
            if ($applicationComponent->slug == $slug) {
                return $applicationComponent;
            }
        }

        return null;
    }
42580
public function getPackagesThatDependOnPackage($slug)
    {
        $plugins = $this->getInstalledPlugins();
        $themes = $this->getInstalledThemes();
        $packages = array_merge($plugins->toArray(), $themes->toArray());

        $dependent_packages = [];

        foreach ($packages as $package_name => $package) {
            if (isset($package['dependencies'])) {
                foreach ($package['dependencies'] as $dependency) {
                    if (is_array($dependency) && isset($dependency['name'])) {
                        $dependency = $dependency['name'];
                    }

                    if ($dependency === $slug) {
                        $dependent_packages[] = $package_name;
                    }
                }
            }
        }

        return $dependent_packages;
    }
371441
public function getInstalledPackage($slug)
    {
        if (isset($this->installed['plugins'][$slug])) {
            return $this->installed['plugins'][$slug];
        }

        if (isset($this->installed['themes'][$slug])) {
            return $this->installed['themes'][$slug];
        }

        return null;
    }
377242
public static function get($slug)
    {
        $locale = I18n::getLocale();
        $slug = array_filter(explode('/', $slug));
        $cache = sprintf('page_%s_locale_%s', md5(serialize($slug)), $locale);
        $page = Cache::read($cache, 'static_pages');

        if (empty($page)) {
            //Sets the (partial) filename
            $filename = implode(DS, $slug);

            //Sets the filename patterns
            $patterns = [$filename . '-' . $locale];
            if (preg_match('/^(\w+)_\w+$/', $locale, $matches)) {
                $patterns[] = $filename . '-' . $matches[1];
            }
            $patterns[] = $filename;

            //Checks if the page exists in APP
            foreach ($patterns as $pattern) {
                $filename = self::getAppPath() . $pattern . '.ctp';

                if (is_readable($filename)) {
                    $page = DS . 'StaticPages' . DS . $pattern;

                    break;
                }
            }

            //Checks if the page exists in each plugin
            foreach (Plugin::all() as $plugin) {
                foreach ($patterns as $pattern) {
                    $filename = self::getPluginPath($plugin) . $pattern . '.ctp';

                    if (is_readable($filename)) {
                        $page = $plugin . '.' . DS . 'StaticPages' . DS . $pattern;

                        break;
                    }
                }
            }

            Cache::write($cache, $page, 'static_pages');
        }

        return $page;
    }
150054
public function getModulePath($slug)
    {
        $module = studly_case($slug);

        if (\File::exists($this->getPath()."/{$module}/")) {
            return $this->getPath()."/{$module}/";
        }

        return $this->getPath()."/{$slug}/";
    }
1086680
protected function getContentBySlug($slug) {
        $this->CmsContent = TableRegistry::get('CmsContent');
        $query = $this->CmsContent->find('all');
        $query->where(['name' => $slug]);
        $data = $query->first();
        return $data;
    }
837332
public function transform($slug)
    {
        if (null === $slug) {
            return;
        }

        // If the slug ends with a slash, return just a slash
        // so the item is used as the index page of that directory
        if (substr($slug, -1) == '/') {
            return '/';
        }

        $array = explode('/', $slug);
        $slug = end($array);

        return $slug;
    }