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


PHP aTools::lock方法代码示例

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


在下文中一共展示了aTools::lock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: lockTree

 /**
  * These have been refactored
  */
 protected function lockTree()
 {
     aTools::lock('tree');
 }
开发者ID:hashir,项目名称:UoA,代码行数:7,代码来源:BaseaActions.class.php

示例2: newAreaVersion

 /**
  * SAVE ANY CHANGES to the actual page object FIRST before you call this method.
  * @param mixed $name
  * @param mixed $action
  * @param mixed $params
  */
 public function newAreaVersion($name, $action, $params = false)
 {
     // Lock this page while adding a new version to it. This prevents race conditions with the
     // assignment of new permids and ranks (fixes #306)
     aTools::lock('page_' . $this->id);
     $diff = '';
     if ($params === false) {
         $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;
         }
//.........这里部分代码省略.........
开发者ID:hashir,项目名称:UoA,代码行数:101,代码来源:PluginaPage.class.php


注:本文中的aTools::lock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。