Skip to content
PHP Ecosystem
Explore

ClientScriptInterface

API reference › yii › web › client › ClientScriptInterface

interfaceyii\web\client\ClientScriptInterface
Since22.0
Sourceframework/web/client/ClientScriptInterface.php

Defines the contract for registering client-side scripts for widgets and components.

Classes implementing this interface are responsible for providing client options and registering scripts in the context of Yii2 widgets and views.

MethodDescriptionDefined by
getClientOptions() abstractReturns client-side options for the specified component.ClientScriptInterface
register() abstractRegisters the client script for the specified widget and view.ClientScriptInterface
abstract public function getClientOptions(yii\web\client\T $object, array<string, mixed> $options = []): array<string, mixed>

Returns client-side options for the specified component.

This method is used to retrieve the options that will be passed to the client-side script.

Parameters

ParameterTypeDescription
$objectyii\web\client\TThe object for which to get the client options.
$optionsarray<string, mixed>Additional options that may influence the client options returned.

Returns

array<string, mixed>: The client options for the widget or component.

abstract public function register(yii\web\client\T $object, yii\web\View $view, array<string, mixed> $options = []): void

Registers the client script for the specified widget and view.

This method is used to register the necessary client-side scripts for the widget in the given view.

Parameters

ParameterTypeDescription
$objectyii\web\client\TThe object whose client script is to be registered.
$viewyii\web\ViewThe view in which the client script should be registered.
$optionsarray<string, mixed>Additional options that may influence the script registration process.