【发布时间】:2023-03-19 03:11:01
【问题描述】:
我创建了一个服务层 AbcService 以允许模块访问常见的代码行。但我需要使用数据库来提取 AbcService 中的值。所以,我需要调用 getAbcTable() 来调用 $service->getServiceLocator()。当我尝试此操作时,我收到一条错误消息,提示“调用未定义的方法 getServiceLocator()。
public function getAbcTable()
{
if (!$this->abcTable) {
$sm = $this->getServiceLocator();
$this->abcTable = $sm->get('Abc\Model\AbcTable');
}
return $this->abcTable;
}
【问题讨论】:
标签: zend-framework2 service-layer