K
K
Kimel2014-08-09 19:48:23
Zend Framework
Kimel, 2014-08-09 19:48:23

FZ2 PHP5 implicit inheritance?

namespace Album\Model;

use Zend\Db\TableGateway\TableGateway;

class AlbumTable
{
    protected $tableGateway;

    public function __construct(TableGateway $tableGateway)
    {
        $this->tableGateway = $tableGateway;
    }
   public function fetchAll()
    {
        $resultSet = $this->tableGateway->select();
        return $resultSet;
    }

Can you please explain. I'm learning ZF2. I don't understand this line
$resultSet = $this->tableGateway->select();
We are assigning a value of unknown origin to the $resultSet variable. $this->tableGateway- this is understandable, we declared it at the very beginning, and from where select (); ?? Our class does not inherit anything, where does this method come from?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Litvinov, 2014-08-09
@Kimel

When creating an AlbumTable object, an object with the TableGateway interface is passed through the constructor and stored in the $tableGateway property. The passed object contains the select() method. When the fetchAll() method is called, the created object delegates the task to the object passed through the constructor with the TableGateway type. I advise you to look at the decorator A
pattern in this book.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question