InlineAction
API reference › yii › base › InlineAction
InlineAction represents an action that is defined as a controller method.
The name of the controller method is available via $actionMethod which is set by the $controller who creates
this action.
For more details and usage information on InlineAction, see the guide article on actions.
Not standalone-compatible: by definition InlineAction targets a controller method, so it cannot be registered in
Module::$actionMap and is always created with a non-null controller.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$actionMethod | string | The controller method that this inline action is associated with. Default: ''. | InlineAction |
$behaviors read-only | array<Behavior<static>> | List of behaviors attached to this component. | Component |
$controller | yii\ | The controller that owns this action, or null when the action runs standalone. via Module::$actionMap Default: null. | Action |
$id | string| | ID of the action; null between construction and dispatcher post-assignment for standalone actions resolved through Module::$actionMap or Module::$actionNamespace. Default: null. | Action |
$module | Module| | The owning module, or null if neither a module nor a controller is attached. Available since 22.0. | Action |
$uniqueId read-only | string | The unique ID of this action among the whole application. | Action |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | InlineAction | |
__call() | Calls the named method which is not a class method. | Component |
__clone() | This method is called after the object is created by cloning an existing one. | Component |
__get() | Returns the value of a component property. | Component |
__isset() | Checks if a property is set, i.e. defined and not null. | Component |
__set() | Sets the value of a component property. | Component |
__unset() | Sets a component property to be null. | Component |
attachBehavior() | Attaches a behavior to this component. | Component |
attachBehaviors() | Attaches a list of behaviors to the component. | Component |
behaviors() | Returns a list of behaviors that this component should behave as. | Component |
canGetProperty() | Returns a value indicating whether a property can be read. | Component |
canSetProperty() | Returns a value indicating whether a property can be set. | Component |
className() static | Returns the fully qualified name of this class. | BaseObject |
detachBehavior() | Detaches a behavior from the component. | Component |
detachBehaviors() | Detaches all behaviors from the component. | Component |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | Component |
getBehavior() | Returns the named behavior object. | Component |
getBehaviors() | Returns all behaviors attached to this component. | Component |
getModule() | Returns the module that owns this action when invoked standalone. | Action |
getUniqueId() | Returns the unique ID of this action among the whole application. | Action |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | Component |
hasMethod() | Returns a value indicating whether a method is defined. | Component |
hasProperty() | Returns a value indicating whether a property is defined for this component. | Component |
init() | Initializes the object. | BaseObject |
off() | Detaches an existing event handler from this component. | Component |
on() | Attaches an event handler to an event. | Component |
runWithParams() | Runs this action with the specified parameters. | InlineAction |
setModule() | Sets the module that owns this action when invoked standalone. | Action |
trigger() | Triggers an event. | Component |
afterRun() protected | This method is called right after run() is executed. | Action |
beforeRun() protected | This method is called right before run() is executed. | Action |
resolveStandaloneParams() protected | Resolves typed parameters of run() when the action is invoked without a hosting controller. | Action |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(string $id, yii\base\T $controller, string $actionMethod, array<string, mixed> $config = [])Parameters
| Parameter | Type | Description |
|---|---|---|
$id | string | The ID of this action |
$controller | yii\ | The controller that owns this action |
$actionMethod | string | The controller method that this inline action is associated with |
$config | array<string, | Name-value pairs that will be used to initialize the object properties |
runWithParams()
Section titled “runWithParams() ”public function runWithParams(array $params): mixedRuns this action with the specified parameters.
This method is mainly invoked by the controller.
Since version 22.0, the controller method is wrapped in the same Action::beforeRun() / afterRun()
guard as standalone Action::runWithParams(), so subclasses overriding beforeRun() to short-circuit the
action also short-circuit inline action methods.
Parameters
| Parameter | Type | Description |
|---|---|---|
$params | array | Action parameters. |
Returns
mixed: The result of the action, or null if beforeRun() returned false.