Find repo by Slug

@param string $slug Repo Slug
@return Repo|null
329037
public function findBySlug($slug)
    {
        foreach ($this->findAll() as $repo) {
            if ($slug == $repo->getSlug()) {
                return $repo;
            }
        }

        return null;
    }
917243
public function checkIfSlugIsUnique($slug)
    {
        $i = 0;
        $this->base_slug = $slug;

        while ($this->post->whereSlug($slug)->get()->count() > 0) {
            $i++;
            $slug = "$this->base_slug-$i";
        }

        return $slug;
    }
816229
protected function getRepository($repoId = null){
        if($repoId === null){
          $repo = $this->getRepository(static::REPOSITORY_NAMESPACE);
        }else{
          $repo = $this->getEntityManager()->getRepository($repoId);
        }
        return $repo;
    }
1374849
public function getProject($slug)
    {
        if (!isset($this->projects[$slug])) {
            throw new \InvalidArgumentException(sprintf('Project "%s" does not exist.', $slug));
        }

        return $this->projects[$slug];
    }
487942
public function findBySlug($slug)
    {
        return $this->slugWorkingRecord->get()->filter($this->slugDbField, $slug)->first();
    }
212047
private function getSlugMapItem($slug)
    {
        $slugMapItem = $this->getSlugMapItemRepository()->findOneBy([
            'slug' => $slug,
        ]);

        if (empty($slugMapItem)) {
            throw $this->createNotFoundException(sprintf('Unable to find slug map item by slug "%s".', $slug));
        }

        return $slugMapItem;
    }
807845
public function getDocumentBySlug($slug)
    {
        $search = $this->repository->createSearch();
        $search->addQuery(new TermQuery('slug', $slug), 'must');

        $results = $this->repository->execute($search);

        if (count($results) === 0) {
            $this->logger && $this->logger->warning(
                sprintf("Can not render snippet for '%s' because content was not found.", $slug)
            );

            return null;
        }

        return $results->current();
    }
1213607
public function bySlug(string $slug = null)
    {
        if (isset($slug)) {
            return $this->apps_by_slug[$slug] ?? null;
        } else {
            return $this->apps_by_slug;
        }
    }
869919
public function view($slug = null)
    {
        //Data can be passed as query string, from a widget
        if ($this->request->getQuery('q')) {
            return $this->redirect([$this->request->getQuery('q')]);
        }

        $slug = Text::slug($slug, ['replacement' => ' ']);

        $tag = $this->PostsTags->Tags->findActiveByTag($slug)
            ->cache((sprintf('tag_%s', md5($slug))), $this->PostsTags->getCacheName())
            ->firstOrFail();

        $page = $this->request->getQuery('page', 1);

        //Sets the cache name
        $cache = sprintf('tag_%s_limit_%s_page_%s', md5($slug), $this->paginate['limit'], $page);

        //Tries to get data from the cache
        list($posts, $paging) = array_values(Cache::readMany(
            [$cache, sprintf('%s_paging', $cache)],
            $this->PostsTags->getCacheName()
        ));

        //If the data are not available from the cache
        if (empty($posts) || empty($paging)) {
            $query = $this->PostsTags->Posts->find('active')
                ->find('forIndex')
                ->matching($this->PostsTags->Tags->getAlias(), function (Query $q) use ($slug) {
                    return $q->where(['tag' => $slug]);
                });
            $posts = $this->paginate($query);

            //Writes on cache
            Cache::writeMany([
                $cache => $posts,
                sprintf('%s_paging', $cache) => $this->request->getParam('paging'),
            ], $this->PostsTags->getCacheName());
        //Else, sets the paging parameter
        } else {
            $this->request = $this->request->withParam('paging', $paging);
        }

        $this->set(compact('posts', 'tag'));
    }
879520
private function packageExists($slug, $package)
    {
        $path = Grav::instance()['locator']->findResource($package->package_type . '://' . $slug);
        Installer::isValidDestination($path);
        return Installer::lastErrorCode();
    }
56767
public function fetchBySlug($slug) {
        $select = $this->select()->where('slug = ?', $slug);
        return $this->fetchRow($select);
    }
81558
public static function get( $slug ) {
		return isset( self::$queues[ $slug ] ) ? self::$queues[ $slug ] : null;
	}
938518
public function getPackagePath($slug)
    {
        if (Str::length($slug) > 3) {
            $package = Str::studly($slug);
        } else {
            $package = Str::upper($slug);
        }

        return $this->getPackagesPath() .DS .$package .DS;
    }
898396
public static function load(string $slug)
    {
        $instance = new static();

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

        return $instance;
    }
171432
public function get_repo_cache( $repo = false ) {
		if ( ! $repo ) {
			$repo = isset( $this->type->slug ) ? $this->type->slug : 'ghu';
		}
		$cache_key = 'ghu-' . md5( $repo );
		$cache     = get_site_option( $cache_key );

		if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
			return false;
		}

		return $cache;
	}
499565
public function setSlug($slug)
    {
        if (!empty($this->slug)) {
            return false;
        }
        $this->slug = $slug;

        return $this;
    }
49039
public static function getPluginFile( $slug ) {

		// Load plugin.php if not already included by core.
		if ( ! function_exists( 'get_plugins' ) ) {
			require ABSPATH . '/wp-admin/includes/plugin.php';
		}

		$plugins = get_plugins();

		foreach ( $plugins as $file => $info ) {

			// Get the basename of the plugin.
			$basename = dirname( plugin_basename( $file ) );
			if ( $basename === $slug ) {
				return $file;
			}
		}

		return null;
	}