Use AbstractTableGateway with a entity and a mapper class

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Use AbstractTableGateway with a entity and a mapper class

Ralf Eggert
Hi again,

I just stumbled upon a problem with the AbstractTableGateway. In the
quick start the constructor looks like this:

---------------------------------------------------------------------
class AlbumTable extends AbstractTableGateway
{
    public function __construct(Adapter $adapter)
    {
        $this->adapter = $adapter;
        $this->resultSetPrototype = new ResultSet();
        $this->resultSetPrototype->setArrayObjectPrototype(new Album());
        $this->initialize();
    }
}
---------------------------------------------------------------------

The result set prototype takes an array object prototype. In this case
it is the entity class Album. When a data set is fetched from the
database then an instance of Album is created and the read data is
passed to an exchangeArray() function of the Album entity class.

So far, so good. But how can I handle this when I don't want the
AlbumTable object to pass back Album objects because my AlbumMapper
should do this job.

How can I handle this? Should I just use the ArrayObject class in the
AlbumTable constructor and let my AlbumMapper stuff the data to the
Album object? Or is there another best practice for this?

Thanks and best regards,

Ralf

--
Ralf Eggert
Geschäftsführer

Travello GmbH
An der Eiche 15
25421 Pinneberg

Geschäftsführer: Ralf Eggert
Amtsgericht Pinneberg HRB 6112 PI

Tel: 04101/8529401
Fax: 04101/8529402
E-Mail: [hidden email]
Web: http://www.travello.de

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]