Skip to content

Request

Type
Class
Namespace
craft\console
Inherits
craft\console\Request » yii\console\Request » yii\base\Request » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable
Uses traits
craft\base\RequestTrait
Since
3.0.0

View source

Public Properties

PropertyDescription
behaviorsyii\base\Behavior – List of behaviors attached to this component.
hadTokenboolean
isActionRequestboolean
isConsoleRequestboolean – The value indicating whether the current request is made via console.
isCpRequestboolean
isLivePreviewboolean – Whether this is a Live Preview request.
isLoginRequestboolean
isPreviewboolean
isSiteRequestboolean
isWebAliasSetDynamicallyboolean
isWebrootAliasSetDynamicallyboolean
paramsarray – The command line arguments.
scriptFilestring – Entry script file path (processed w/ realpath()).
scriptFilenamestring – The requested script name being used to access Craft (e.g. “index.
siteTokenstring, null – The token, or null if there isn’t one.
tokenstring, null – The token, or null if there isn’t one.

hadToken

Type
boolean
Default value
null
Access
Read-only
Since
3.6.0

View source

isActionRequest

Type
boolean
Default value
null
Access
Read-only

View source

isCpRequest

Type
boolean
Default value
null
Access
Read-only

View source

isLivePreview

Type
boolean
Default value
null
Access
Read-only

Whether this is a Live Preview request.

View source

isLoginRequest

Type
boolean
Default value
null
Access
Read-only
Since
3.2.0

View source

isPreview

Type
boolean
Default value
null
Access
Read-only
Since
3.2.1

View source

isSiteRequest

Type
boolean
Default value
null
Access
Read-only

View source

siteToken

Type
string, null
Default value
null
Access
Read-only
Since
3.6.0

The token, or null if there isn’t one.

View source

token

Type
string, null
Default value
null
Since
3.2.0

The token, or null if there isn’t one.

View source

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__clone()This method is called after the object is created by cloning an existing one.
__construct()Constructor.
__get()Returns the value of a component property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets the value of a component property.
__unset()Sets a component property to be null.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
behaviors()Returns a list of behaviors that this component should behave as.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
getHadToken()Returns whether the request initially had a token.
getIsActionRequest()Returns whether a specific controller action was requested. (Narrator: There wasn't.)
getIsConsoleRequest()Returns a value indicating whether the current request is made via command line.
getIsCpRequest()Returns whether the control panel was requested. (Narrator: It wasn't.)
getIsLivePreview()Returns whether this is a classic Live Preview request.
getIsLoginRequest()Returns whether this was a Login request.
getIsPreview()Returns whether this is an element preview request.
getIsSiteRequest()Returns whether the front end site was requested. (Narrator: It wasn't.)
getParams()Returns the command line arguments.
getScriptFile()Returns entry script file path.
getScriptFilename()Returns the requested script name being used to access Craft (e.g. “index.php”).
getSiteToken()Returns the site token submitted with the request, if there is one.
getToken()Returns the token submitted with the request, if there is one.
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined for this component.
init()Initializes the object.
off()Detaches an existing event handler from this component.
on()Attaches an event handler to an event.
resolve()Resolves the current request into a route and the associated parameters.
setIsConsoleRequest()Sets the value indicating whether the current request is made via command line.
setParams()Sets the command line arguments.
setScriptFile()Sets the entry script file path.
setToken()Sets the token value.
trigger()Triggers an event.

getHadToken()

Since
3.6.0

Returns whether the request initially had a token.

View source

Returns

boolean

getIsActionRequest()

Returns whether a specific controller action was requested. (Narrator: There wasn't.)

View source

Returns

boolean

getIsCpRequest()

Returns whether the control panel was requested. (Narrator: It wasn't.)

View source

Returns

boolean

getIsLivePreview()

DEPRECATED

Deprecated in 3.2.0

Returns whether this is a classic Live Preview request.

View source

Returns

boolean – Whether this is a Live Preview request.

getIsLoginRequest()

Since
3.2.0

Returns whether this was a Login request.

View source

Returns

boolean

getIsPreview()

Since
3.2.1

Returns whether this is an element preview request.

View source

Returns

boolean

getIsSiteRequest()

Returns whether the front end site was requested. (Narrator: It wasn't.)

View source

Returns

boolean

getSiteToken()

Since
3.6.0

Returns the site token submitted with the request, if there is one.

View source

Returns

string, null – The token, or null if there isn’t one.

getToken()

Since
3.2.0

Returns the token submitted with the request, if there is one.

View source

Returns

string, null – The token, or null if there isn’t one.

init()

Initializes the object.

This method is invoked at the end of the constructor after the object is initialized with the given configuration.

View source

setToken()

Since
3.6.0

Sets the token value.

View source

Arguments

  • $token (?string)