You are here

public function SiteimproveUtils::setSessionUrl in Siteimprove 8

Save URL in session.

Parameters

\Drupal\Core\Entity\EntityInterface|null $entity: Node or taxonomy term entity object.

Throws

\Drupal\Core\Entity\EntityMalformedException

File

src/SiteimproveUtils.php, line 202

Class

SiteimproveUtils
Utility functions for Siteimprove.

Namespace

Drupal\siteimprove

Code

public function setSessionUrl(?EntityInterface $entity) {

  // Check if user has access.
  if ($this->currentUser
    ->hasPermission('use siteimprove')) {
    $urls = $this
      ->getEntityUrls($entity);

    // Save friendly url in SESSION.
    foreach ($urls as $url) {
      $_SESSION['siteimprove_url'][] = $url;
    }
  }
}