Skip to content

Commit

Permalink
Add an additional parameter to GPM::findPackage to avoid throwing an …
Browse files Browse the repository at this point in the history
…exception, for use in Twig, re #1008
  • Loading branch information
flaviocopes committed Jan 22, 2017
1 parent 6968e2e commit 4d904e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

1. [](#new)
* Added a new `Collection::merge()` method to allow merging of multiple collections [#1258](https://github.com/getgrav/grav/pull/1258)
1. [](#improved)
* Add an additional parameter to GPM::findPackage to avoid throwing an exception, for use in Twig [#1008](https://github.com/getgrav/grav/issues/1008)
1. [](#bugfix)
* Fixed an issue when page collection with header-based `sort.by` returns an array [#1264](https://github.com/getgrav/grav/issues/1264)
* Fix `Response` object to handle `303` redirects when `open_basedir` in effect [#1267](https://github.com/getgrav/grav/issues/1267)

# v1.1.14
## 01/18/2017

Expand Down
7 changes: 6 additions & 1 deletion system/src/Grav/Common/GPM/GPM.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,10 @@ public function getRepository()
/**
* Searches for a Package in the repository
* @param string $search Can be either the slug or the name
* @param bool $ignore_exception True if should not fire an exception (for use in Twig)
* @return Remote\Package Package if found, FALSE if not
*/
public function findPackage($search)
public function findPackage($search, $ignore_exception = false)
{
$search = strtolower($search);

Expand All @@ -470,6 +471,10 @@ public function findPackage($search)
throw new \RuntimeException("The cache/gpm folder is not writable. Please check the folder permissions.");
}

if ($ignore_exception) {
return false;
}

throw new \RuntimeException("GPM not reachable. Please check your internet connection or check the Grav site is reachable");
}

Expand Down

0 comments on commit 4d904e6

Please sign in to comment.