當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Trigger::saveAttributes方法代碼示例

本文整理匯總了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';
    }
}
開發者ID:joshgillies,項目名稱:mysource-matrix,代碼行數:47,代碼來源:upgrade_future_trigger_actions.php


注:本文中的Trigger::saveAttributes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。