0

I use ZF2... How can call service manager in a viewhelper? My probem is that. I use slug module for sef link. ( link : https://packagist.org/packages/olliebrennan/zf2-slug-generator )

And i need to call it's service from a view helper. But how can do this?

class CommonHelper extends AbstractHelper
{
    public function getSefLink($link){
        //my problem is here, how can i call service locator??
        $slug = $this->getServiceLocator()->get('SeoUrl\Slug');
        return $slug->create($link);
    }
}
tereško
  • 58,060
  • 25
  • 98
  • 150
Yargicx
  • 1,704
  • 3
  • 16
  • 36

1 Answers1

1

duplicate of Zend Framework 2 Service in View Helper

$this->getServiceLocator()->getServiceLocator();
Community
  • 1
  • 1
Exlord
  • 5,009
  • 4
  • 31
  • 51