diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php index 8cfae1369..1722586f3 100644 --- a/system/src/Grav/Common/GPM/GPM.php +++ b/system/src/Grav/Common/GPM/GPM.php @@ -141,4 +141,29 @@ class GPM extends Iterator { public function getRepository() { return $this->repository; } + + public function findPackage($search) { + $search = strtolower($search); + if ($found = $this->getRepositoryTheme($search)) { + return $found; + } + + if ($found = $this->getRepositoryPlugin($search)) { + return $found; + } + + foreach ($this->getRepositoryThemes() as $slug => $theme) { + if ($search == $slug || $search == $theme->name) { + return $theme; + } + } + + foreach ($this->getRepositoryPlugins() as $slug => $plugin) { + if ($search == $slug || $search == $plugin->name) { + return $plugin; + } + } + + return false; + } }