当前位置: 首页>>代码示例>>PHP>>正文


PHP Trigger::attr方法代码示例

本文整理汇总了PHP中Trigger::attr方法的典型用法代码示例。如果您正苦于以下问题:PHP Trigger::attr方法的具体用法?PHP Trigger::attr怎么用?PHP Trigger::attr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Trigger的用法示例。


在下文中一共展示了Trigger::attr方法的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::attr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。