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


PHP AppController::delete_folder方法代码示例

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


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

示例1: beforeDelete

 public function beforeDelete(Event $event, Entity $entity)
 {
     $upload_root_offset = Configure::read('UPLOAD_ROOT_OFFSET');
     $upload_root = Configure::read('UPLOAD_ROOT');
     $id = $entity->id;
     $job_id = $entity->job_id;
     // delete creative folder and all its contents
     AppController::delete_folder($upload_root_offset . DS . $upload_root . DS . $job_id . DS . $id);
     /*
     		$Files = TableRegistry::get('Files');
     		$files = $Files->find('all',['conditions'=>['creative_id'=>$id]])->toArray();
     		if( !empty($files) ) {
     	    	foreach($files as $row){
     			    $file_path = $upload_root_offset . $row['file'];
     			    if( file_exists($file_path) ) {
     					if ( is_dir($file_path) ){
     						if( AppController::delete_folder($file_path) ) {
     							
     						}
     					} else if( unlink($file_path) ) {
     						
     					}
     				}
     		    }
     	    }
     */
 }
开发者ID:dlowetz,项目名称:asset-preview,代码行数:27,代码来源:CreativesTable.php

示例2: beforeDelete

 public function beforeDelete(Event $event, Entity $entity)
 {
     $upload_root_offset = Configure::read('UPLOAD_ROOT_OFFSET');
     $file_path = $upload_root_offset . $entity->file;
     if ($entity->archived === 1) {
         $file_path = $upload_root_offset . dirname($entity->file) . DS . Configure::read('UPLOAD_VERSION_DIR') . DS . 'v_' . $entity->version . '_' . basename($file_path);
     }
     if ($entity->version_id) {
         $Files = TableRegistry::get('Files');
         // delete versions record if this was the only file left in the group
         //echo 'count:'.$Files->find('all')->where(['version_id'=>$entity->version_id])->count();
         if ($Files->find('all')->where(['version_id' => $entity->version_id])->count() <= 1) {
             $Versions = TableRegistry::get('Versions');
             if ($version = $Versions->get($entity->version_id)) {
                 $Versions->delete($version);
             }
         }
     }
     if (file_exists($file_path) && $file_path !== Configure::read("UPLOAD_ROOT")) {
         if (is_dir($file_path)) {
             if (AppController::delete_folder($file_path)) {
                 //return true;
             }
         } else {
             if (unlink($file_path)) {
                 //echo 'file - '.$file_path.' -  deleted';
                 //return true;
             }
         }
     }
     return true;
 }
开发者ID:dlowetz,项目名称:asset-preview,代码行数:32,代码来源:FilesTable.php

示例3: beforeDelete

 public function beforeDelete(Event $event, Entity $entity)
 {
     $root = Configure::read('UPLOAD_ROOT_OFFSET') . Configure::read('UPLOAD_ROOT');
     $file_path = $root . DS . $entity->id;
     if (file_exists($file_path) && $entity->id) {
         if (is_dir($file_path)) {
             if (AppController::delete_folder($file_path)) {
                 return true;
             }
         } else {
             if (unlink($file_path)) {
                 return true;
             }
         }
     }
     return true;
 }
开发者ID:dlowetz,项目名称:asset-preview,代码行数:17,代码来源:JobsTable.php

示例4: page_exit

 public function page_exit()
 {
     $this->layout = null;
     $this->render(false);
     $Files = TableRegistry::get('Files');
     // delete files in limbo
     $files = $Files->find('all', ['conditions' => ["committed" => 0, "user_id" => $this->request->data['user_id']]])->toArray();
     if (!empty($files)) {
         foreach ($files as $file) {
             $file_path = $file['file'];
             if ($file_path === $this->upload_root) {
                 return false;
             }
             $id = $file['id'];
             if (file_exists($this->upload_root_offset . $file_path)) {
                 if (is_dir($this->upload_root_offset . $file_path)) {
                     if (AppController::delete_folder($this->upload_root_offset . $file_path)) {
                         if ($Files->delete($Files->get($id))) {
                             //die(json_encode(array("status"=>"success","file"=>$file['Files'])));
                         }
                     }
                 } else {
                     if (unlink($this->upload_root_offset . $file_path)) {
                         if ($Files->delete($Files->get($id))) {
                             //die( json_encode(array("status"=>"success","file"=>$file['Files'])) );
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:dlowetz,项目名称:asset-preview,代码行数:32,代码来源:ManagerController.php


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