Class lispa\amos\chat\DataProvider

Inheritancelispa\amos\chat\DataProvider » yii\data\ActiveDataProvider » yii\data\BaseDataProvider » yii\base\Component » yii\base\Object
Implementsyii\base\Arrayable, yii\base\Configurable, yii\data\DataProviderInterface
Uses Traitsyii\base\ArrayableTrait

Class DataProvider

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$behaviors yii\base\Behavior[] List of behaviors attached to this component yii\base\Component
$count integer The number of data models in the current page. yii\data\BaseDataProvider
$db yii\db\Connection|array|string The DB connection object or the application component ID of the DB connection. yii\data\ActiveDataProvider
$id string An ID that uniquely identifies the data provider among all data providers. yii\data\BaseDataProvider
$key string|callable The column that is used as the key of the data models. yii\data\ActiveDataProvider
$keys array The list of key values corresponding to $models. yii\data\BaseDataProvider
$models array The list of data models in the current page. lispa\amos\chat\DataProvider
$pagination yii\data\Pagination|false The pagination object. yii\data\BaseDataProvider
$query yii\db\QueryInterface The query that is used to fetch data models and $totalCount if it is not explicitly set. yii\data\ActiveDataProvider
$sort yii\data\Sort|boolean The sorting object. yii\data\BaseDataProvider
$totalCount integer Total number of possible data models. yii\data\BaseDataProvider

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\Component
__clone() This method is called after the object is created by cloning an existing one. yii\base\Component
__construct() Constructor. yii\base\Object
__get() Returns the value of a component property. yii\base\Component
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Component
__set() Sets the value of a component property. yii\base\Component
__unset() Sets a component property to be null. yii\base\Component
attachBehavior() Attaches a behavior to this component. yii\base\Component
attachBehaviors() Attaches a list of behaviors to the component. yii\base\Component
behaviors() Returns a list of behaviors that this component should behave as. yii\base\Component
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Component
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Component
className() Returns the fully qualified name of this class. yii\base\Object
detachBehavior() Detaches a behavior from the component. yii\base\Component
detachBehaviors() Detaches all behaviors from the component. yii\base\Component
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component. yii\base\Component
extraFields() Returns the list of fields that can be expanded further and returned by toArray(). yii\base\ArrayableTrait
fields() Returns the list of fields that should be returned by default by toArray() when no specific fields are specified. lispa\amos\chat\DataProvider
getBehavior() Returns the named behavior object. yii\base\Component
getBehaviors() Returns all behaviors attached to this component. yii\base\Component
getCount() Returns the number of data models in the current page. yii\data\BaseDataProvider
getKeys() Returns the key values associated with the data models. yii\data\BaseDataProvider
getModels() Returns the data models in the current page. lispa\amos\chat\DataProvider
getPagination() Returns the pagination object used by this data provider. yii\data\BaseDataProvider
getSort() Returns the sorting object used by this data provider. yii\data\BaseDataProvider
getTotalCount() Returns the total number of data models. yii\data\BaseDataProvider
hasEventHandlers() Returns a value indicating whether there is any handler attached to the named event. yii\base\Component
hasMethod() Returns a value indicating whether a method is defined. yii\base\Component
hasProperty() Returns a value indicating whether a property is defined for this component. yii\base\Component
init() Initializes the DB connection component. yii\data\ActiveDataProvider
off() Detaches an existing event handler from this component. yii\base\Component
on() Attaches an event handler to an event. yii\base\Component
prepare() Prepares the data models and keys. yii\data\BaseDataProvider
refresh() Refreshes the data provider. yii\data\BaseDataProvider
setKeys() Sets the key values associated with the data models. yii\data\BaseDataProvider
setModels() Sets the data models in the current page. yii\data\BaseDataProvider
setPagination() Sets the pagination for this data provider. yii\data\BaseDataProvider
setSort() Sets the sort definition for this data provider. yii\data\ActiveDataProvider
setTotalCount() Sets the total number of data models. yii\data\BaseDataProvider
toArray() Converts the model into an array. yii\base\ArrayableTrait
trigger() Triggers an event. yii\base\Component

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
prepareKeys() Prepares the keys associated with the currently available data models. yii\data\ActiveDataProvider
prepareModels() Prepares the data models that will be made available in the current page. yii\data\ActiveDataProvider
prepareTotalCount() Returns a value indicating the total number of data models in this data provider. yii\data\ActiveDataProvider
resolveFields() Determines which fields can be returned by toArray(). yii\base\ArrayableTrait

Property Details

$models public property

The list of data models in the current page.

public array getModels ( )
public void setModels ( $models )

Method Details

fields() public method

Returns the list of fields that should be returned by default by toArray() when no specific fields are specified.

A field is a named element in the returned array by toArray().

This method should return an array of field names or field definitions. If the former, the field name will be treated as an object property name whose value will be used as the field value. If the latter, the array key should be the field name while the array value should be the corresponding field definition which can be either an object property name or a PHP callable returning the corresponding field value. The signature of the callable should be:

function ($model, $field) {
    // return field value
}

For example, the following code declares four fields:

  • email: the field name is the same as the property name email;
  • firstName and lastName: the field names are firstName and lastName, and their values are obtained from the first_name and last_name properties;
  • fullName: the field name is fullName. Its value is obtained by concatenating first_name and last_name.
return [
    'email',
    'firstName' => 'first_name',
    'lastName' => 'last_name',
    'fullName' => function ($model) {
        return $model->first_name . ' ' . $model->last_name;
    },
];
public array fields ( )
return array

The list of field names or field definitions.

getModels() public method

Returns the data models in the current page.

public array getModels ( )
return array

The list of data models in the current page.