0 follower

Final Class Yiisoft\Yii\DataView\ListView\ListItemContext

InheritanceYiisoft\Yii\DataView\ListView\ListItemContext

ListItemContext provides contextual information about the current item being rendered in a Yiisoft\Yii\DataView\ListView\ListView.

This immutable data class encapsulates all the contextual information needed when rendering individual list items, making it available to closures and view templates.

See also Yiisoft\Yii\DataView\ListView\ListView The widget that creates and uses this context.

Property Details

Hide inherited properties

$data public property
public array|object $data null
$index public property
public integer $index null
$key public property
public integer|string $key null
$widget public property

Method Details

Hide inherited methods

__construct() public method

public __construct( array|object $data, integer|string $key, integer $index, Yiisoft\Yii\DataView\ListView\ListView $widget ): mixed
$data array|object

The current data being rendered. This can be either an array or an object representing the current item's data.

$key integer|string

The key value associated with the current data. This is typically used as a unique identifier for the item and can be either an integer or a string.

$index integer

The zero-based index of the data in the array. This represents the item's position in the overall dataset, starting from 0.

$widget Yiisoft\Yii\DataView\ListView\ListView

The list view object that is rendering the current item. This provides access to the ListView instance for accessing widget configuration and methods.

                public function __construct(
    public readonly array|object $data,
    public readonly int|string $key,
    public readonly int $index,
    public readonly ListView $widget,
) {}