Zend Framework 2のドキュメントには、次のように書かれZend\Db\TableGateway\TableGateway
ています。
[Zend \ Db \ TableGateway \ TableGateway]コンストラクターは、単一の機能オブジェクト、FeatureSetオブジェクト、または機能オブジェクトの配列の3つの異なる形式で機能を取得できます。
そしてTableGateway
コンストラクターは実際に型をチェックします。
したがって、TableGateway
コンストラクターの4番目の引数は、互換性があるFeature\AbstractFeature
か、互換性のあるオブジェクトFeature\FeatureSet
の配列である必要がFeature\AbstractFeature
あります。
Get Startedチュートリアルのモデル部分では、タイプのオブジェクトTableGateway
が作成され、Zend\Db\ResultSet\ResultSet
4番目の引数として取得されます。
class Module
{
// getAutoloaderConfig() and getConfig() methods here
// Add this method:
public function getServiceConfig()
{
return array(
'factories' => array(
...
'AlbumTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Album());
return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
},
),
);
}
}
ResultSet
ではありませんinstanceof
AbstractFeature
。しかし、それは機能します。
それはどのように機能しますか?