/** * @inheritDoc */ public function url($path = '', $query = '', $absolute = FALSE, $fragment = NULL, $frontend = FALSE, $forceBackend = FALSE) { $query = html_entity_decode($query); $url = \Drupal\civicrm\CivicrmHelper::parseURL("{$path}?{$query}"); // Not all links that CiviCRM generates are Drupal routes, so we use the weaker ::fromUri method. try { $url = \Drupal\Core\Url::fromUri("base:{$url['path']}", array('query' => $url['query'], 'fragment' => $fragment, 'absolute' => $absolute))->toString(); } catch (Exception $e) { // @Todo: log to watchdog $url = ''; } // Special case: CiviCRM passes us "*path*?*query*" as a skeleton, but asterisks // are invalid and Drupal will attempt to escape them. We unescape them here: if ($path == '*path*') { // First remove trailing equals sign that has been added since the key '?*query*' has no value. $url = rtrim($url, '='); $url = urldecode($url); } return $url; }
/** * @inheritDoc */ public function url($path = '', $query = '', $absolute = FALSE, $fragment = NULL, $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE) { $query = html_entity_decode($query); $url = \Drupal\civicrm\CivicrmHelper::parseURL("{$path}?{$query}"); try { $url = \Drupal::url($url['route_name'], array(), array('query' => $url['query'], 'absolute' => $absolute, 'fragment' => $fragment)); } catch (Exception $e) { $url = ''; } if ($htmlize) { $url = htmlentities($url); } return $url; }