Commit 6af79d8b authored by Taylor Otwell's avatar Taylor Otwell

Added ability to dynamically create links to named routes using the HTML class.

parent b90c6ddc
...@@ -76,6 +76,34 @@ class HTML { ...@@ -76,6 +76,34 @@ class HTML {
return static::link($url, $title, $attributes, false, true); return static::link($url, $title, $attributes, false, true);
} }
/**
* Generate an HTML link to a route.
*
* @param string $name
* @param string $title
* @param array $parameters
* @param array $attributes
* @return string
*/
public static function link_to_route($name, $title, $parameters = array(), $attributes = array(), $https = false)
{
return static::link(URL::to_route($name, $parameters, $https), $title, $attributes);
}
/**
* Generate an HTTPS HTML link to a route.
*
* @param string $name
* @param string $title
* @param array $parameters
* @param array $attributes
* @return string
*/
public static function link_to_secure_route($name, $title, $parameters = array(), $attributes = array())
{
return static::link_to_route($name, $title, $parameters, $attributes, true);
}
/** /**
* Generate an HTML mailto link. * Generate an HTML mailto link.
* *
...@@ -250,4 +278,28 @@ class HTML { ...@@ -250,4 +278,28 @@ class HTML {
return $safe; return $safe;
} }
/**
* Magic Method for handling dynamic static methods.
*/
public static function __callStatic($method, $parameters)
{
// -------------------------------------------------------
// Handle the dynamic creation of links to secure routes.
// -------------------------------------------------------
if (strpos($method, 'link_to_secure_') === 0)
{
array_unshift($parameters, substr($method, 15));
return forward_static_call_array('HTML::link_to_secure_route', $parameters);
}
// -------------------------------------------------------
// Handle the dynamic creation of links to routes.
// -------------------------------------------------------
if (strpos($method, 'link_to_') === 0)
{
array_unshift($parameters, substr($method, 8));
return forward_static_call_array('HTML::link_to_route', $parameters);
}
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment