Craft Triggers (2.x)

TriggersService extends Component
in package

Table of Contents

CONFIG_KEY  = 'triggers'
EVENT_AFTER_APPLYING_ACTIONS  = 'after-applying-actions'
EVENT_AFTER_CHECKING_CONDITIONS  = 'after-checking-conditions'
EVENT_AFTER_DELETE  = 'after-delete'
EVENT_AFTER_SAVE  = 'after-save'
EVENT_BEFORE_APPLY_DELETE  = 'before-apply-delete'
EVENT_BEFORE_APPLYING_ACTIONS  = 'before-applying-actions'
EVENT_BEFORE_CHECKING_CONDITIONS  = 'before-checking-conditions'
EVENT_BEFORE_DELETE  = 'before-delete'
EVENT_BEFORE_SAVE  = 'before-save'
EVENT_REGISTER_ACTIONS  = 'register-actions'
EVENT_REGISTER_CONDITIONS  = 'register-conditions'
EVENT_REGISTER_TRIGGERS  = 'register-triggers'
$_actions  : array<string|int, mixed>
$_conditions  : array<string|int, mixed>
$_registeredActions  : array<string|int, mixed>
$_registeredConditions  : array<string|int, mixed>
$_registeredTriggers  : array<string|int, mixed>
$_triggers  : array<string|int, mixed>
delete()  : bool
Delete a trigger
getActionById()  : ActionInterface
Get an action by id
getActionClass()  : string
Get an action class by handle
getActionsForTrigger()  : array<string|int, mixed>
Get the actions for a trigger
getActiveTriggers()  : array<string|int, mixed>
Get active triggers
getAllActions()  : array<string|int, mixed>
Get all actions
getAllConditions()  : array<string|int, mixed>
Get all conditions
getAllTriggers()  : array<string|int, mixed>
Get all triggers
getConditionById()  : ConditionInterface
Get a condition by id
getConditionClass()  : string
Get the condition class for a handle
getConditionsForGroup()  : array<string|int, mixed>
Get the conditions for a group
getConditionsForTrigger()  : array<string|int, mixed>
Get the conditions for a trigger
getRegisteredAction()  : ActionInterface
Get a registered action by handle
getRegisteredActions()  : array<string|int, mixed>
Get registered actions
getRegisteredCondition()  : ConditionInterface
Get a registered condition by handle
getRegisteredConditions()  : array<string|int, mixed>
Get registered conditions
getRegisteredTrigger()  : TriggerInterface
Get a registered trigger by handle
getRegisteredTriggers()  : array<string|int, mixed>
Get registered triggers
getTriggerById()  : TriggerInterface
Get trigger by id
getTriggerClass()  : string
Get the class for a trigger handle
handleChanged()  : mixed
Handle project config change
handleDeleted()  : mixed
Handle project config deletion
incrementTriggerCounter()  : mixed
Increment the triggered counter for a trigger id
isActionRegistered()  : bool
Is an action handle registered
isConditionRegistered()  : bool
is a condition handle registered
isTriggerRegistered()  : bool
Is a trigger handle registered
onTriggerTriggered()  : mixed
Callback when a trigger is triggered
rebuildConfig()  : mixed
Respond to rebuild config event
save()  : bool
Save a trigger
getActionRecordByUid()  : Action
Get action record by uid
getConditionRecordByUid()  : Condition
Get condition record by uid
getTriggerRecordByUid()  : Trigger
Get trigger record by uid
handleChangedAction()  : int
Apply config changes to an action
handleChangedCondition()  : array<string|int, mixed>
Apply config changes to a condition
registerActions()  : mixed
Registers actions
registerConditions()  : mixed
Registers conditions
registerTriggers()  : mixed
Registers triggers

Constants

EVENT_AFTER_APPLYING_ACTIONS

public mixed EVENT_AFTER_APPLYING_ACTIONS = 'after-applying-actions'

EVENT_AFTER_CHECKING_CONDITIONS

public mixed EVENT_AFTER_CHECKING_CONDITIONS = 'after-checking-conditions'

EVENT_BEFORE_APPLY_DELETE

public mixed EVENT_BEFORE_APPLY_DELETE = 'before-apply-delete'

EVENT_BEFORE_APPLYING_ACTIONS

public mixed EVENT_BEFORE_APPLYING_ACTIONS = 'before-applying-actions'

EVENT_BEFORE_CHECKING_CONDITIONS

public mixed EVENT_BEFORE_CHECKING_CONDITIONS = 'before-checking-conditions'

EVENT_BEFORE_DELETE

public mixed EVENT_BEFORE_DELETE = 'before-delete'

EVENT_REGISTER_ACTIONS

public mixed EVENT_REGISTER_ACTIONS = 'register-actions'

EVENT_REGISTER_CONDITIONS

public mixed EVENT_REGISTER_CONDITIONS = 'register-conditions'

EVENT_REGISTER_TRIGGERS

public mixed EVENT_REGISTER_TRIGGERS = 'register-triggers'

Properties

$_registeredActions

protected array<string|int, mixed> $_registeredActions

$_registeredConditions

protected array<string|int, mixed> $_registeredConditions

$_registeredTriggers

protected array<string|int, mixed> $_registeredTriggers

Methods

getActionClass()

Get an action class by handle

public getActionClass(string $handle) : string
Parameters
$handle : string
Return values
string

getActionsForTrigger()

Get the actions for a trigger

public getActionsForTrigger(int $triggerId) : array<string|int, mixed>
Parameters
$triggerId : int
Return values
array<string|int, mixed>

getActiveTriggers()

Get active triggers

public getActiveTriggers() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAllActions()

Get all actions

public getAllActions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAllConditions()

Get all conditions

public getAllConditions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAllTriggers()

Get all triggers

public getAllTriggers() : array<string|int, mixed>
Return values
array<string|int, mixed>

getConditionClass()

Get the condition class for a handle

public getConditionClass(string $handle) : string
Parameters
$handle : string
Return values
string

getConditionsForGroup()

Get the conditions for a group

public getConditionsForGroup(int $groupId) : array<string|int, mixed>
Parameters
$groupId : int
Return values
array<string|int, mixed>

getConditionsForTrigger()

Get the conditions for a trigger

public getConditionsForTrigger(int $triggerId) : array<string|int, mixed>
Parameters
$triggerId : int
Return values
array<string|int, mixed>

getRegisteredActions()

Get registered actions

public getRegisteredActions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRegisteredConditions()

Get registered conditions

public getRegisteredConditions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRegisteredTriggers()

Get registered triggers

public getRegisteredTriggers() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTriggerClass()

Get the class for a trigger handle

public getTriggerClass(string $handle) : string
Parameters
$handle : string
Return values
string

handleChanged()

Handle project config change

public handleChanged(ConfigEvent $event) : mixed
Parameters
$event : ConfigEvent
Return values
mixed

handleDeleted()

Handle project config deletion

public handleDeleted(ConfigEvent $event) : mixed
Parameters
$event : ConfigEvent
Return values
mixed

incrementTriggerCounter()

Increment the triggered counter for a trigger id

public incrementTriggerCounter(int $triggerId) : mixed
Parameters
$triggerId : int
Return values
mixed

isActionRegistered()

Is an action handle registered

public isActionRegistered(string $handle) : bool
Parameters
$handle : string
Return values
bool

isConditionRegistered()

is a condition handle registered

public isConditionRegistered(string $handle) : bool
Parameters
$handle : string
Return values
bool

isTriggerRegistered()

Is a trigger handle registered

public isTriggerRegistered(string $handle) : bool
Parameters
$handle : string
Return values
bool

onTriggerTriggered()

Callback when a trigger is triggered

public onTriggerTriggered(TriggerInterface $trigger[, array<string|int, mixed> $data = [] ]) : mixed
Parameters
$trigger : TriggerInterface
$data : array<string|int, mixed> = []
Return values
mixed

rebuildConfig()

Respond to rebuild config event

public rebuildConfig(RebuildConfigEvent $e) : mixed
Parameters
$e : RebuildConfigEvent
Return values
mixed

save()

Save a trigger

public save(Trigger $trigger[, bool $validate = true ]) : bool
Parameters
$trigger : Trigger
$validate : bool = true
Return values
bool

getActionRecordByUid()

Get action record by uid

protected getActionRecordByUid(string $uid) : Action
Parameters
$uid : string
Return values
Action

getConditionRecordByUid()

Get condition record by uid

protected getConditionRecordByUid(string $uid) : Condition
Parameters
$uid : string
Return values
Condition

getTriggerRecordByUid()

Get trigger record by uid

protected getTriggerRecordByUid(string $uid) : Trigger
Parameters
$uid : string
Return values
Trigger

handleChangedAction()

Apply config changes to an action

protected handleChangedAction(Trigger $trigger, array<string|int, mixed> $data) : int
Parameters
$trigger : Trigger
$data : array<string|int, mixed>
Return values
int

handleChangedCondition()

Apply config changes to a condition

protected handleChangedCondition(Trigger $trigger, array<string|int, mixed> $data[, int|null $group_id = null ]) : array<string|int, mixed>
Parameters
$trigger : Trigger
$data : array<string|int, mixed>
$group_id : int|null = null
Return values
array<string|int, mixed>

registerActions()

Registers actions

protected registerActions() : mixed
Return values
mixed

registerConditions()

Registers conditions

protected registerConditions() : mixed
Return values
mixed

registerTriggers()

Registers triggers

protected registerTriggers() : mixed
Return values
mixed

Search results