Thanks to this thread I've cleared myself about using decorations of the Model inside the View scope. I had a thread about arguing that the pagination (filtering, ordering, etc.) logic must not be implemented by the Model, but by the View because it's a pure View requirement. I've put my Pagination (etc.) plugin into the Controller (into it's constructor model initialization), but while reading this thread I've realized it should be in the View. So, now I have:
Controller
Code: Select all
class User extends CollectionController
{
...
public function getUsers
{
$this->model = new UserCollectionModel();
$this->view('getUsers', $model);
}
} Code: Select all
$model = new GridCollection($this->model);
$users = $model->getAll();
...
(... DO SOMETHING WITH $users ...)Code: Select all
class GridCollection extends DecoratorCollection_Model
{
public function __construct($model, $conf = null)
{
parent::__construct(new FilteredCollection(new OrderedCollection(new LimitedCollection($model, $conf), $conf), $conf), $conf);
}
}I think that the View *must* be somehow coupled to the Model by coupling it to a specific Interface. Either it's the Model API or the result object structure, it must be. In this case, (de)coupling can be easily solved by using an Adapter pattern.