Skip to content
PHP Ecosystem
Explore

InlineAction

API reference › yii › base › InlineAction

classyii\base\InlineAction
ExtendsAction » Component » BaseObject
ImplementsConfigurable
Since2.0
Sourceframework/base/InlineAction.php

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.

PropertyTypeDescriptionDefined by
$actionMethodstringThe controller method that this inline action is associated with. Default: ''.InlineAction
$behaviors read-onlyarray<Behavior<static>>List of behaviors attached to this component.Component
$controlleryii\base\T|nullThe controller that owns this action, or null when the action runs standalone. via Module::$actionMap Default: null.Action
$idstring|nullID of the action; null between construction and dispatcher post-assignment for standalone actions resolved through Module::$actionMap or Module::$actionNamespace. Default: null.Action
$moduleModule|nullThe owning module, or null if neither a module nor a controller is attached. Available since 22.0.Action
$uniqueId read-onlystringThe unique ID of this action among the whole application.Action
MethodDescriptionDefined 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() staticReturns 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() protectedThis method is called right after run() is executed.Action
beforeRun() protectedThis method is called right before run() is executed.Action
resolveStandaloneParams() protectedResolves typed parameters of run() when the action is invoked without a hosting controller.Action
public function __construct(string $id, yii\base\T $controller, string $actionMethod, array<string, mixed> $config = [])

Parameters

ParameterTypeDescription
$idstringThe ID of this action
$controlleryii\base\TThe controller that owns this action
$actionMethodstringThe controller method that this inline action is associated with
$configarray<string, mixed>Name-value pairs that will be used to initialize the object properties
public function runWithParams(array $params): mixed

Runs 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

ParameterTypeDescription
$paramsarrayAction parameters.

Returns

mixed: The result of the action, or null if beforeRun() returned false.