You are here

public function BusinessRulesUtil::getPreviousUri in Business Rules 8

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

Return the previous Url.

Return value

\Drupal\Core\Url|null The Url.

File

src/Util/BusinessRulesUtil.php, line 557

Class

BusinessRulesUtil
Class BusinessRulesUtil.

Namespace

Drupal\business_rules\Util

Code

public function getPreviousUri() {
  try {
    $previousUrl = $_SERVER['HTTP_REFERER'];
    $fake_request = Request::create($previousUrl);
    $url_object = $this->container
      ->get('path.validator')
      ->getUrlIfValid($fake_request
      ->getRequestUri());
    if ($url_object) {
      return $url_object;
    }
  } catch (\Exception $e) {
    $this->logger
      ->error($e);
  }
  return NULL;
}