ClientScriptInterface
API reference › yii › web › client › ClientScriptInterface
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.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
getClientOptions() abstract | Returns client-side options for the specified component. | ClientScriptInterface |
register() abstract | Registers the client script for the specified widget and view. | ClientScriptInterface |
Method details
Section titled “Method details”getClientOptions()
Section titled “getClientOptions() ”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
| Parameter | Type | Description |
|---|---|---|
$object | yii\ | The object for which to get the client options. |
$options | array<string, | Additional options that may influence the client options returned. |
Returns
array<string, mixed>: The client options for the widget or component.
register()
Section titled “register() ”abstract public function register(yii\web\client\T $object, yii\web\View $view, array<string, mixed> $options = []): voidRegisters 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
| Parameter | Type | Description |
|---|---|---|
$object | yii\ | The object whose client script is to be registered. |
$view | yii\ | The view in which the client script should be registered. |
$options | array<string, | Additional options that may influence the script registration process. |