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


PHP GO::modelCache方法代码示例

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


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

示例1: _checkExistingModelFolder

 private function _checkExistingModelFolder($model, $folder, $mustExist = false)
 {
     \GO::debug("Check existing model folder " . $model->className() . "(ID:" . $model->id . " Folder ID: " . $folder->id . " ACL ID: " . $model->findAclId() . ")");
     if (!$folder->fsFolder->exists()) {
         //throw new \Exception("Fs folder doesn't exist! ".$folder->fsFolder->path());
         \GO::debug("Deleting it because filesystem folder doesn't exist");
         $folder->readonly = 1;
         //makes sure acl is not deleted
         $folder->delete(true);
         if ($mustExist) {
             return $this->_createNewModelFolder($model);
         } else {
             return 0;
         }
     }
     //todo test this:
     //      if(!isset($model->acl_id) && empty($params['mustExist'])){
     //          //if this model is not a container like an addressbook but a contact
     //          //then delete the folder if it's empty.
     //          $ls = $folder->fsFolder->ls();
     //          if(!count($ls) && $folder->fsFolder->mtime()<time()-60){
     //              $folder->delete();
     //              $response['files_folder_id']=$model->files_folder_id=0;
     //              $model->save();
     //              return $response['files_folder_id'];
     //          }
     //      }
     $currentPath = $folder->path;
     $newPath = $model->buildFilesPath();
     if (!$newPath) {
         return false;
     }
     if (\GO::router()->getControllerAction() == 'checkdatabase') {
         //Always ensure folder exists on check database
         $destinationFolder = \GO\Files\Model\Folder::model()->findByPath(dirname($newPath), true, array('acl_id' => $model->findAclId(), 'readonly' => 1));
     }
     if ($currentPath != $newPath) {
         \GO::debug("Moving folder " . $currentPath . " to " . $newPath);
         //model has a new path. We must move the current folder
         $destinationFolder = \GO\Files\Model\Folder::model()->findByPath(dirname($newPath), true, array('acl_id' => $model->findAclId(), 'readonly' => 1));
         //sometimes the folder must be moved into a folder with the same. name
         //for example:
         //projects/Name must be moved into projects/Name/Name
         //then we temporarily move it to a temp name
         if ($destinationFolder->id == $folder->id || $destinationFolder->fsFolder->isSubFolderOf($folder->fsFolder)) {
             \GO::debug("Destination folder is the same!");
             $folder->name = uniqid();
             $folder->systemSave = true;
             $folder->save(true);
             \GO::debug("Moved folder to temp:" . $folder->fsFolder->path());
             \GO::modelCache()->remove("GO\\Files\\Model\\Folder");
             $destinationFolder = \GO\Files\Model\Folder::model()->findByPath(dirname($newPath), true);
             \GO::debug("Now moving to:" . $destinationFolder->fsFolder->path());
         }
         if ($destinationFolder->id == $folder->id) {
             throw new \Exception("Same ID's!");
         }
         $fsFolder = new \GO\Base\Fs\Folder($newPath);
         //          $fsFolder->appendNumberToNameIfExists();
         if ($existingFolder = $destinationFolder->hasFolder($fsFolder->name())) {
             \GO::debug("Merging into existing folder." . $folder->path . ' (' . $folder->id . ') -> ' . $existingFolder->path . ' (' . $existingFolder->id . ')');
             //if (!empty($model->acl_id))
             $existingFolder->acl_id = $model->findAclId();
             $existingFolder->visible = 0;
             $existingFolder->readonly = 1;
             $existingFolder->save(true);
             $folder->systemSave = true;
             $existingFolder->moveContentsFrom($folder, true);
             //delete empty folder.
             $folder->readonly = 1;
             //makes sure acl is not deleted
             $folder->delete(true);
             return $existingFolder->id;
         } else {
             //              if ($model->acl_id>0)
             //                  $folder->acl_id = $model->acl_id;
             //              else
             //                  $folder->acl_id=0;
             $folder->acl_id = $model->findAclId();
             $folder->name = $fsFolder->name();
             $folder->parent_id = $destinationFolder->id;
             $folder->systemSave = true;
             $folder->visible = 0;
             $folder->readonly = 1;
             if ($folder->isModified()) {
                 if (!$folder->save(true)) {
                     throw new \Exception(var_export($folder->getValidationErrors(), true));
                 }
             }
         }
     } else {
         \GO::debug("No change needed");
         //          if ($model->acl_id>0)
         //              $folder->acl_id = $model->acl_id;
         //          else
         //              $folder->acl_id=0;
         $folder->acl_id = $model->findAclId();
         $folder->systemSave = true;
         $folder->visible = 0;
         $folder->readonly = 1;
//.........这里部分代码省略.........
开发者ID:ajaboa,项目名称:crmpuan,代码行数:101,代码来源:FolderController.php


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