0
我想構建自己的可調用列表並從AbstractFactory訪問它。如何定義自己的可調用列表並從AbstractFactory訪問此列表
/**
* Get the service config
*/
public function getServiceConfig()
{
return array(
'invokables' => array(
),
'foo-invokables' => array(
'FooService' => 'Foo\Service\FooService',
)
);
}
工廠應該檢查此列表以查看別名是否在foo-invokable列表中。
public function canCreateServiceWithName(ServiceLocatorInterface $objServiceManager, $sCanonicalName, $sRequestedName) {
// TODO check if the $sRequestedName is contained with in the foo-invokables return true
}
在此先感謝。
如果「請求名稱」已經是「invokables」配置中,那麼你應該從來沒有獲得到'AbstractFactory'。如果服務管理器找不到具有該名稱的任何註冊服務,則服務管理器將僅使用抽象工廠作爲回退。 – AlexP 2014-10-29 12:36:10