Url.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_View
  17. * @subpackage Helper
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @version $Id$
  20. * @license http://framework.zend.com/license/new-bsd New BSD License
  21. */
  22. /** Zend_View_Helper_Abstract.php */
  23. require_once 'Zend/View/Helper/Abstract.php';
  24. /**
  25. * Helper for making easy links and getting urls that depend on the routes and router
  26. *
  27. * @package Zend_View
  28. * @subpackage Helper
  29. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class Zend_View_Helper_Url extends Zend_View_Helper_Abstract
  33. {
  34. /**
  35. * Generates an url given the name of a route.
  36. *
  37. * @access public
  38. *
  39. * @param array $urlOptions Options passed to the assemble method of the Route object.
  40. * @param mixed $name The name of a Route to use. If null it will use the current Route
  41. * @param bool $reset Whether or not to reset the route defaults with those provided
  42. * @return string Url for the link href attribute.
  43. */
  44. public function url(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
  45. {
  46. $router = Zend_Controller_Front::getInstance()->getRouter();
  47. return $router->assemble($urlOptions, $name, $reset, $encode);
  48. }
  49. }