Download the PHP package quieteroks/yii-presenter without Composer
On this page you can find all versions of the php package quieteroks/yii-presenter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download quieteroks/yii-presenter
More information about quieteroks/yii-presenter
Files in quieteroks/yii-presenter
Package yii-presenter
Short Description Presenter for yii framework
License GPL-3.0-or-later
Informations about the package yii-presenter
Yii2 presenter
The presenter is view part of model layer. It retrieves data from the model, and formats for display in view.
The presenter is simple way to decorate model for view of you MVC framework. The best way for presenter is to convert model layer to view and replace view part itself.
But, you can put all view logic according to model in presenter and also provide all data for view from the presenter. All methods have to be encapsulated in common interface and after it they have to replace the presenter (maybe even with model) to fully change view part for other models.
Typical example of such presenters are following for CRUD operation in admin panel:
- Presenter for the model’s list through the GridView
- Presenter for specification of the model through the DetailView
- Presenter of the form for creation and updating models
Installation
Install with composer cli:
Or add package in composer.json
to require
part:
Usage
The presenter can decorate array
, object
or yii\base\Model
and access all decorated type as presented object.
-
Minimal presenter object:
-
The presenter can hide or rename base properties:
- The presenter can decorate and add property via getter method:
Access priority
The presenter finds and gives access to property in a priority:
- Pubic property of the presenter
- Getter method in the presenter
- Getter method in the decorated model
- Public properties in the decorated model
All getter method are wrapped in cameCase: created_at => getCreatedAt
it’s also can be relevant for getter method in the decorated model.
There is no access for methods like getCreated_at.