From 9019c6e2f61edb60ce35537407ae39ea05f7b1b9 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 24 Feb 2012 08:08:56 -0600 Subject: [PATCH] added link_to_action method to html class. --- laravel/html.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/laravel/html.php b/laravel/html.php index 83b3de00..9268acc8 100644 --- a/laravel/html.php +++ b/laravel/html.php @@ -180,6 +180,30 @@ public static function link_to_route($name, $title, $parameters = array(), $attr return static::link(URL::to_route($name, $parameters), $title, $attributes); } + /** + * Generate an HTML link to a controller action. + * + * An array of parameters may be specified to fill in URI segment wildcards. + * + * + * // Generate a link to the "home@index" action + * echo HTML::link_to_action('home@index', 'Home'); + * + * // Generate a link to the "user@profile" route and add some parameters + * echo HTML::link_to_action('user@profile', 'Profile', array('taylor')); + * + * + * @param string $action + * @param string $title + * @param array $parameters + * @param array $attributes + * @return string + */ + public static function link_to_action($action, $title, $parameters = array(), $attributes = array()) + { + return static::link(URL::to_action($action, $parameters), $title, $attributes); + } + /** * Generate an HTML mailto link. *