I have view helper from ZF2 that doesn't work anymore with ZF3 because of ServiceLocatorAwareInterface
deprecation.
What's the proper way to refactor that class:
<?php
namespace Site\View\Helper;
use Zend\View\Helper\AbstractHelper;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class SlidersList extends AbstractHelper implements ServiceLocatorAwareInterface
{
protected $_serviceLocator;
public function __invoke()
{
return $this->getView()->render(
'partials/sliders',
array('sliders' => $this->getServiceLocator()->getServiceLocator()->get('Sliders/Model/Table/SlidersTable')->fetchAll(true))
);
}
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->_serviceLocator = $serviceLocator;
}
public function getServiceLocator()
{
return $this->_serviceLocator;
}
}
Should I use view helper factory to inject service locator and if yes, how it should be done?