Inheritance: implements Symfony\Component\Routing\RouterInterface
Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function add_download_link($route, $title, $msg = null)
 {
     $link_properties = array('href' => $this->router->generate($route), 'title' => $this->language->lang($title), 'download' => $this->language->lang('DOWNLOAD'));
     if ($msg !== null) {
         $link_properties['msg'] = htmlspecialchars_decode($this->language->lang($msg));
     }
     $this->download[] = $link_properties;
 }
Esempio n. 2
0
 /**
  * Generate a URL to a route
  *
  * @param string	$route		Name of the route to travel
  * @param array	$params		String or array of additional url parameters
  * @param bool	$is_amp		Is url using & (true) or & (false)
  * @param string|bool		$session_id	Possibility to use a custom session id instead of the global one
  * @param bool|string		$reference_type The type of reference to be generated (one of the constants)
  * @return string The URL already passed through append_sid()
  */
 public function route($route, array $params = array(), $is_amp = true, $session_id = false, $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH)
 {
     $anchor = '';
     if (isset($params['#'])) {
         $anchor = '#' . $params['#'];
         unset($params['#']);
     }
     $context = new RequestContext();
     $context->fromRequest($this->symfony_request);
     if ($this->config['force_server_vars']) {
         $context->setHost($this->config['server_name']);
         $context->setScheme(substr($this->config['server_protocol'], 0, -3));
         $context->setHttpPort($this->config['server_port']);
         $context->setHttpsPort($this->config['server_port']);
         $context->setBaseUrl(rtrim($this->config['script_path'], '/'));
     }
     $script_name = $this->symfony_request->getScriptName();
     $page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name);
     $base_url = $context->getBaseUrl();
     // Append page name if base URL does not contain it
     if (!empty($page_name) && strpos($base_url, '/' . $page_name) === false) {
         $base_url .= '/' . $page_name;
     }
     // If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it.
     $base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url);
     // We need to update the base url to move to the directory of the app.php file if the current script is not app.php
     if ($page_name !== 'app.php' && !$this->config['force_server_vars']) {
         if (empty($this->config['enable_mod_rewrite'])) {
             $base_url = str_replace('/app.' . $this->php_ext, '/' . $this->phpbb_root_path . 'app.' . $this->php_ext, $base_url);
         } else {
             $base_url .= preg_replace(get_preg_expression('path_remove_dot_trailing_slash'), '$2', $this->phpbb_root_path);
         }
     }
     $base_url = $this->request->escape($this->filesystem->clean_path($base_url), true);
     $context->setBaseUrl($base_url);
     $this->router->setContext($context);
     $route_url = $this->router->generate($route, $params, $reference_type);
     if ($is_amp) {
         $route_url = str_replace(array('&', '&'), array('&', '&'), $route_url);
     }
     if ($reference_type === UrlGeneratorInterface::RELATIVE_PATH && empty($this->config['enable_mod_rewrite'])) {
         $route_url = 'app.' . $this->php_ext . '/' . $route_url;
     }
     return append_sid($route_url . $anchor, false, $is_amp, $session_id, true);
 }
Esempio n. 3
0
 public function get_generator()
 {
     $this->create_new_url_generator();
     return parent::get_generator();
 }
Esempio n. 4
0
 /**
  * Returns path from route name
  *
  * @param string	$route_name
  *
  * @return string
  */
 public function route($route_name)
 {
     $url = $this->router->generate($route_name);
     return $url;
 }
Esempio n. 5
0
 /**
  * Returns path from route name
  *
  * @param string	$route_name
  * @param array		$parameters
  *
  * @return string
  */
 public function route($route_name, $parameters = array())
 {
     $url = $this->router->generate($route_name, $parameters);
     return $url;
 }