本文整理汇总了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) ) {
}
}
}
}
*/
}
示例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;
}
示例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;
}
示例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'])) );
}
}
}
}
}
}
}