本文整理汇总了PHP中Trigger::saveAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Trigger::saveAttributes方法的具体用法?PHP Trigger::saveAttributes怎么用?PHP Trigger::saveAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Trigger
的用法示例。
在下文中一共展示了Trigger::saveAttributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgradeTrigger
/**
* Upgrade the Set Future Permissions and Set Future Status trigger actions
* present in existing Trigger assets to the new values expected in version 0.2
* of these assets
*
* @param Trigger &$trigger The Trigger Asset to upgrade
*
* @return void
* @access public
*/
function upgradeTrigger(Trigger &$trigger)
{
$trigger_actions = $trigger->attr('actions');
$trigger_modified = FALSE;
foreach ($trigger_actions as $key => &$trigger_action) {
$trigger_action_data =& $trigger_action['data'];
// Set Future Permissions and Status triggers < v0.2 will not have an "offset_used" value
if (($trigger_action['type'] == 'trigger_action_set_future_permissions' || $trigger_action['type'] == 'trigger_action_set_future_status') && !isset($trigger_action_data['offset_used'])) {
// Modify data associated with the Trigger Action (using a reference for ease and fun)
// Add new "offset_used" value
$trigger_action_data['offset_used'] = FALSE;
// Convert to new "by_attr_value" when_type and enable offset if one was specified
if ($trigger_action_data['when_type'] == 'attr_interval' || $trigger_action_data['when_type'] == 'attr_exact') {
$trigger_action_data['when_type'] = 'by_attr_value';
$trigger_action_data['offset_used'] = $trigger_action_data['when_type'] == 'attr_interval';
}
// Convert "explicit_interval" to "explicit_exact", as the offset is now handled separately
if ($trigger_action_data['when_type'] == 'explicit_interval') {
$trigger_action_data['when_type'] = 'explicit_exact';
$trigger_action_data['offset_used'] = TRUE;
}
// Restock the main Trigger Actions array for this Trigger
$trigger_actions[$key] = $trigger_action;
$trigger_modified = TRUE;
}
}
if ($trigger_modified) {
// Supply the new Trigger Actions values and save the Trigger if it was modified
echo "\n- Upgrading Trigger " . $trigger->id . '... ';
// Ok we need the Attributes lock now...
$GLOBALS['SQ_SYSTEM']->acquireLock($trigger->id, 'attributes');
$trigger->setAttrValue('actions', $trigger_actions);
$trigger->saveAttributes();
$GLOBALS['SQ_SYSTEM']->releaseLock($trigger->id, 'attributes');
echo 'done';
}
}