mirror of
https://github.com/getgrav/grav.git
synced 2026-07-13 18:33:28 +02:00
Improve error when trying to install a plugin/theme from the command line and GPM is unreachable
Previously it listed four times `PHP Warning: Invalid argument supplied for foreach()...`, now it fails with an error message
This commit is contained in:
@@ -323,13 +323,20 @@ class GPM extends Iterator
|
||||
return $found;
|
||||
}
|
||||
|
||||
foreach ($this->getRepositoryThemes() as $slug => $theme) {
|
||||
$themes = $this->getRepositoryThemes();
|
||||
$plugins = $this->getRepositoryPlugins();
|
||||
|
||||
if (!$themes && !$plugins) {
|
||||
throw new \RuntimeException("GPM not reachable. Please check your internet connection or check the Grav site is reachable");
|
||||
}
|
||||
|
||||
if ($themes) foreach ($themes as $slug => $theme) {
|
||||
if ($search == $slug || $search == $theme->name) {
|
||||
return $theme;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getRepositoryPlugins() as $slug => $plugin) {
|
||||
if ($plugins) foreach ($plugins as $slug => $plugin) {
|
||||
if ($search == $slug || $search == $plugin->name) {
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user