ServerEventDataSource

The server-event data source for the Table widget.

 class Backend\Widgets\Table\ServerEventDataSource
extends Backend\Widgets\Table\DataSourceBase

Extends

Class Description
DataSourceBase

Base class for the Table widget data sources.

Traits

Trait Description
Emitter

Adds event related features to any class.

Properties

inherited protected $emitterEventCollection : array

Inherited from Emitter

Collection of registered events.

inherited protected $emitterEventSorted : array

Inherited from Emitter

Sorted collection of events.

inherited protected $emitterSingleEventCollection : array

Inherited from Emitter

Collection of registered events to be fired once only.

inherited protected $keyColumn : string

Inherited from DataSourceBase

Specifies a name of record's key column

inherited protected $offset : int

Inherited from DataSourceBase

Internal record offset

Methods

public createRecord ($data, $placement, $relativeToKey) : void

Updates a record in the data source.

Parameters
Property Description
$data
mixed
$placement
mixed
$relativeToKey
mixed
Returns
void

public deleteRecord ($key) : array

Removes a record from the data source.

Parameters
Property Description
$key
mixed
Returns
array

Returns the remaining records.

public getAllRecords ()

Returns all records in the data source.

This method is specific only for the client memory data sources.

Returns
mixed

public getCount () : int

Returns a total number of records in the data source.

Returns
int

public getRecords (int $offset, int $count) : array

Return records from the data source.

Parameters
Property Description
$offset
int

Specifies the offset of the first record to return, zero-based.

$count
int

Specifies the number of records to return.

Returns
array

Returns the records. If there are no more records, returns an empty array.

public initRecords (array $records)

Initializes records in the data source.

The method doesn't replace existing records and could be called multiple times in order to fill the data source.

Parameters
Property Description
$records
array

Records to initialize in the data source.

Returns
mixed

public purge ()

Removes all records from the data source.

Returns
mixed

public searchRecords ($query, $offset, $count)

Identical to getRecords except provided with a search query.

Parameters
Property Description
$query
mixed
$offset
mixed
$count
mixed
Returns
mixed

public updateRecord ($key, $data) : void

Updates a record in the data source.

Parameters
Property Description
$key
mixed
$data
mixed
Returns
void

inherited public bindEvent (string | Closure | QueuedClosure $event, mixed $callback = null, integer $priority) : self

Inherited from Emitter

Create a new event binding.

Parameters
Property Description
$event
string | Closure | QueuedClosure
$callback
mixed

when the third parameter is omitted and a Closure or QueuedClosure is provided this parameter is used as an integer this is used as priority variable

$priority
integer
Returns
self

inherited public bindEventOnce (string | Closure | QueuedClosure $event, QueuedClosure | Closure | null $callback = null) : self

Inherited from Emitter

Create a new event binding that fires once only

Parameters
Property Description
$event
string | Closure | QueuedClosure
$callback
QueuedClosure | Closure | null

When a Closure or QueuedClosure is provided as the first parameter this parameter can be omitted

Returns
self

inherited public construct (string $keyColumn = "id")

Inherited from DataSourceBase

Class constructor.

Parameters
Property Description
$keyColumn
string

Specifies a name of the key column.

Returns
mixed

inherited public fireEvent (string $event, array $params = [], boolean $halt = false) : array | mixed | null

Inherited from Emitter

Fire an event and call the listeners.

Parameters
Property Description
$event
string

Event name

$params
array

Event parameters

$halt
boolean

Halt after first non-null result

Returns
array | mixed | null

If halted, the first non-null result. If not halted, an array of event results. Returns null if no listeners returned a result.

inherited public readRecords (integer $count = 10) : array

Inherited from DataSourceBase

Returns a set of records from the data source.

Parameters
Property Description
$count
integer

Specifies the number of records to return.

Returns
array

Returns the records. If there are no more records, returns an empty array.

inherited public reset ()

Inherited from DataSourceBase

Rewinds the the data source to the first record.

Use this method with the readRecords() method.

Returns
mixed

inherited public unbindEvent (string | array | object $event = null) : self

Inherited from Emitter

Destroys an event binding.

Parameters
Property Description
$event
string | array | object

Event to destroy

Returns
self

inherited protected emitterEventSortEvents (string $eventName) : void

Inherited from Emitter

Sort the listeners for a given event by priority.

Parameters
Property Description
$eventName
string
Returns
void

inherited protected parseEventAndPayload (mixed $event, mixed $payload = null) : array

Inherited from Emitter

Parse the given event and payload and prepare them for dispatching.

Parameters
Property Description
$event
mixed
$payload
mixed
Returns
array
Copyright © 2024 Winter CMS