非推奨のため、ZF3 では動作しなくなった ZF2 のビュー ヘルパーがありますServiceLocatorAwareInterface
。
そのクラスをリファクタリングする適切な方法は何ですか:
<?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;
}
}
ビュー ヘルパー ファクトリを使用してサービス ロケーターを挿入する必要がありますか? はいの場合、どのように行う必要がありますか?