You are here

public function BusinessRulesUtil::getCurrentUri in Business Rules 2.x

Same name and namespace in other branches
  1. 8 src/Util/BusinessRulesUtil.php \Drupal\business_rules\Util\BusinessRulesUtil::getCurrentUri()

Return the current Url.

Return value

\Drupal\Core\Url|null The Url.

File

src/Util/BusinessRulesUtil.php, line 504

Class

BusinessRulesUtil
Class BusinessRulesUtil.

Namespace

Drupal\business_rules\Util

Code

public function getCurrentUri() {

  // $current = $this->request->server->get('REQUEST_URI');.
  $current = $_SERVER['REQUEST_URI'];
  $fake_request = Request::create($current);
  $url_object = $this->container
    ->get('path.validator')
    ->getUrlIfValid($fake_request
    ->getRequestUri());
  if ($url_object) {
    return $url_object;
  }
  return NULL;
}