-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/2830 #2830
* develop: During form submission, start buffer, then flush it. #2820 and #2448 and #2788 Set window.cf2 if not an object #2821 #2814 schedule deletes in cf2 fiel fields and cleanup that handler a bit #2814 schedule deletes #2814 handle deleting directory if empty Only try to delete file, if it exists #2814 Test to prove that the delete file job will make an uncaught exception in some cases #2814 Make new job for deleting tests work #2814 New job for deleting files #2814 - failing tests Make new utility methods needed for #2814 and #2794 work Failing tests for utility methods needed for #2814 and #2794 #2814 rm dead code and add inline docs to existing delete job # Conflicts: # cf2/functions.php
- Loading branch information
Showing
1,773 changed files
with
160,591 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
|
||
namespace calderawp\calderaforms\cf2\Jobs; | ||
|
||
|
||
/** | ||
* Class DeleteFileJob | ||
* | ||
* Delete a file at a later time | ||
* | ||
* @since 1.8.0 | ||
*/ | ||
class DeleteFileJob extends Job | ||
{ | ||
|
||
/** | ||
* Path file is stored in | ||
* | ||
* @since 1.8.0 | ||
* | ||
* @var string | ||
*/ | ||
protected $path; | ||
|
||
/** | ||
* DeleteFileJob constructor. | ||
* | ||
* @since 1.8.0 | ||
* | ||
* @param string $path Path file is stored in | ||
*/ | ||
public function __construct($path) | ||
{ | ||
$this->path = $path; | ||
} | ||
|
||
/** @inheritdoc */ | ||
public function handle() | ||
{ | ||
if ( file_exists($this->path) ) { | ||
unlink($this->path); | ||
} | ||
|
||
if( file_exists( $this->dirName() ) && $this->isEmptyDir() ){ | ||
rmdir(dirname($this->path)); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Check if is empty directory | ||
* | ||
* @since 1.8.0 | ||
* | ||
* @return bool | ||
*/ | ||
protected function isEmptyDir() | ||
{ | ||
foreach ( new \DirectoryIterator($this->dirName()) as $fileInfo ) { | ||
if ( $fileInfo->isDot() ) { | ||
continue; | ||
}; | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
* Get name of directory file is in | ||
* | ||
* @since 1.8.0 | ||
* | ||
* @return string | ||
*/ | ||
protected function dirName() | ||
{ | ||
return dirname($this->path); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.