Initial skeleton in place with ZF2 submodule pointed at current master
[zf2.biz/application_blanche.git] / modules / Application / src / Application / View / Helper / Url.php
1 <?php
2 namespace Application\View\Helper;
3
4 use Zend\View\Helper\AbstractHelper,
5     Zend\Mvc\Router\RouteStack;
6
7 class Url extends AbstractHelper
8 {
9     protected $router;
10
11     public function setRouter(RouteStack $router)
12     {
13         $this->router = $router;
14     }
15
16     public function direct($params = array(), $options = array())
17     {
18         if (null === $this->router) {
19             return '';
20         }
21
22         // Remove trailing '/index' from generated URLs.
23         $url = $this->router->assemble($params, $options);
24         if ((6 <= strlen($url)) && '/index' == substr($url, -6)) {
25             $url = substr($url, 0, strlen($url) - 6);
26         }
27
28         return $url;
29     }
30 }