Added method to find a package in the repository

This commit is contained in:
Djamil Legato
2014-09-08 18:02:28 -07:00
parent a44193db16
commit 5f41beccde

View File

@@ -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;
}
}