本文整理汇总了PHP中aTools::unlock方法的典型用法代码示例。如果您正苦于以下问题:PHP aTools::unlock方法的具体用法?PHP aTools::unlock怎么用?PHP aTools::unlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aTools
的用法示例。
在下文中一共展示了aTools::unlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unlockTree
/**
* It's OK to call this if there is no lock.
* Eases its use in calls like flunkUnless
*/
protected function unlockTree()
{
aTools::unlock();
}
示例2: newAreaVersion
//.........这里部分代码省略.........
$params = array();
}
$this->begin();
// We use the slots already queried as a basis for the new version,
// because that makes rollback easy to implement etc. But we
// MUST fetch the latest copy of the area object to make sure
// we don't create duplicate versions.
// When we're adding a new slot to an area we need to make sure it
// it is first in the hash so it gets ranked first
if ($action === 'add') {
// New: support for specifying whether the new slot is at top or bottom of the area
$top = !isset($params['top']) || $params['top'];
$diff = isset($params['slot']) ? "<strong>" . aString::limitCharacters($params['slot']->getSearchText(), 20) . "</strong>" : '';
$newSlots = $this->getSlotsByAreaName($name, $params['slot'], $top);
} else {
$newSlots = $this->getSlotsByAreaName($name);
}
$area = aAreaTable::retrieveOrCreateByPageIdAndName($this->id, $name);
if (!$area->id) {
// We need an ID established
$area->save();
}
$areaVersion = new aAreaVersion();
$areaVersion->area_id = $area->id;
$areaVersion->version = $area->latest_version + 1;
// Don't crash on an anon edit, such as an edit made by a task
if (sfContext::hasInstance() && sfContext::getInstance()->getUser()->getGuardUser()) {
$areaVersion->author_id = sfContext::getInstance()->getUser()->getGuardUser()->getId();
}
if ($action === 'delete') {
if (isset($newSlots[$params['permid']])) {
$diff = '<strike>' . aString::limitCharacters($newSlots[$params['permid']]->getSearchText(), 20) . '</strike>';
unset($newSlots[$params['permid']]);
}
} elseif ($action === 'update') {
$oldText = '';
if (isset($newSlots[$params['permid']])) {
$oldText = $newSlots[$params['permid']]->getSearchText();
}
$newText = isset($params['slot']) ? $params['slot']->getSearchText() : '';
$fullDiff = aString::diff($oldText, $newText);
$diff = '';
if (!empty($fullDiff['onlyin1'])) {
$diff .= '<strike>' . aString::limitCharacters($fullDiff['onlyin1'][0], 20) . '</strike>';
}
if (!empty($fullDiff['onlyin2'])) {
$diff .= '<strong>' . aString::limitCharacters($fullDiff['onlyin2'][0], 20) . '</strong>';
}
$newSlots[$params['permid']] = $params['slot'];
} elseif ($action === 'variant') {
$newSlot = $newSlots[$params['permid']]->copy();
if (!$newSlot) {
throw new sfException('Slot does not exist');
}
$variants = sfConfig::get('app_a_slot_variants');
if (!isset($variants[$newSlot->type][$params['variant']])) {
throw new sfException('Variant not defined for this slot type');
}
$newSlot->variant = $params['variant'];
// Must have an id before we can make an AreaVersionSlot referencing it
$newSlot->save();
$newSlots[$params['permid']] = $newSlot;
$diff = $newSlot->variant;
} elseif ($action === 'add') {
// We took care of this in the getArea call
} elseif ($action === 'sort') {
$diff = '[Reordered slots]';
$newerSlots = array();
foreach ($params['permids'] as $permid) {
$newerSlots[$permid] = $newSlots[$permid];
}
$newSlots = $newerSlots;
} elseif ($action === 'revert') {
// TODO: actually represent the changes carried out by the reversion
// in the diff. That's rather expensive because many slots in the area
// may have changed all at once.
$diff = '[Reverted to older version]';
# We just want whatever is in the slot cache copied to a new version
}
$areaVersion->diff = $diff;
$areaVersion->save();
$rank = 1;
foreach ($newSlots as $permid => $slot) {
// After unset, foreach shows keys but has null values
if (!$slot) {
continue;
}
$areaVersionSlot = new aAreaVersionSlot();
$areaVersionSlot->slot_id = $slot->id;
$areaVersionSlot->permid = $permid;
$areaVersionSlot->area_version_id = $areaVersion->id;
$areaVersionSlot->rank = $rank++;
$areaVersionSlot->save();
}
$area->latest_version++;
$area->save();
$this->requestSearchUpdate();
$this->end();
aTools::unlock();
}