mirror of
https://github.com/getgrav/grav.git
synced 2025-10-26 07:56:07 +01:00
Added $grav['uri]->getCurrentUri() function to get Grav\Framework\Uri instance for the current URL.
This commit is contained in:
@@ -3,9 +3,10 @@
|
||||
|
||||
1. [](#new)
|
||||
* Added `Grav\Framework\Uri` classes extending PSR-7 `HTTP message UriInterface` implementation
|
||||
* Added `$grav['uri]->getCurrentUri()` function to get `Grav\Framework\Uri` instance for the current URL.
|
||||
* Added ability to have `php` version dependencies in GPM assets
|
||||
1. [](#bugfix)
|
||||
* Fixed issue with remote PHP version determination for Grav updates
|
||||
* Fixed issue with remote PHP version determination for Grav updates
|
||||
|
||||
# v1.4.0-rc.2
|
||||
## 02/15/2018
|
||||
|
||||
@@ -9,12 +9,16 @@
|
||||
namespace Grav\Common;
|
||||
|
||||
use Grav\Common\Page\Page;
|
||||
use Grav\Framework\Uri\UriFactory;
|
||||
use Grav\Framework\Uri\UriPartsFilter;
|
||||
|
||||
class Uri
|
||||
{
|
||||
const HOSTNAME_REGEX = '/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/';
|
||||
|
||||
/** @var \Grav\Framework\Uri\Uri */
|
||||
protected static $currentUri;
|
||||
|
||||
public $url;
|
||||
|
||||
// Uri parts.
|
||||
@@ -596,6 +600,20 @@ class Uri
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current Uri.
|
||||
*
|
||||
* @return \Grav\Framework\Uri\Uri
|
||||
*/
|
||||
public static function getCurrentUri()
|
||||
{
|
||||
if (!static::$currentUri) {
|
||||
static::$currentUri = UriFactory::createFromEnvironment($_SERVER);
|
||||
}
|
||||
|
||||
return static::$currentUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this an external URL? if it starts with `http` then yes, else false
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user