In the chapter "Database and models" of the current (2.1) ZF2 User Guide there a code snippet, I don't understand:
(block "Using ServiceManager to configure the table gateway and inject into the AlbumTable")
...
class Module
{
// getAutoloaderConfig() and getConfig() methods here
// Add this method:
public function getServiceConfig()
{
return array(
'factories' => array(
'Album\Model\AlbumTable' => function($sm) {
$tableGateway = $sm->get('AlbumTableGateway');
$table = new AlbumTable($tableGateway);
return $table;
},
'AlbumTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Album());
return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
},
),
);
}
}
The variable $sm
will be later an instance of the Zend\ServiceManager\ServiceManager
, right? The method Zend\ServiceManager\ServiceManager#get(...) expects a classname as first argument. But there is no class AlbumTableGateway. There are only two model classes: Album\Model\Album and Album\Model\AlbumTable.
Is it an error in the guide or am I understanding the code wrongly?
Thanks