|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Canvas\Cli\Tasks; |
|
4
|
|
|
|
|
5
|
|
|
use Phalcon\Cli\Task as PhTask; |
|
|
|
|
|
|
6
|
|
|
use Canvas\Models\FileSystem; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class AclTask |
|
10
|
|
|
* |
|
11
|
|
|
* @package Canvas\Cli\Tasks; |
|
12
|
|
|
* |
|
13
|
|
|
* @property \Canvas\Acl\Manager $acl |
|
14
|
|
|
* @property \Phalcon\Di $di |
|
15
|
|
|
*/ |
|
16
|
|
|
class FileSystemTask extends PhTask |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Create the default roles of the system |
|
20
|
|
|
* |
|
21
|
|
|
* @return void |
|
22
|
|
|
*/ |
|
23
|
|
|
public function mainAction() |
|
24
|
|
|
{ |
|
25
|
|
|
echo 'Main action for FileSystem Task'; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Default roles for the crm system |
|
30
|
|
|
* |
|
31
|
|
|
* @return void |
|
32
|
|
|
*/ |
|
33
|
|
|
public function purgeImagesAction(array $params):void |
|
34
|
|
|
{ |
|
35
|
|
|
//Option to fully delete or softdelete an image |
|
36
|
|
|
$fullDelete = $params[0]; |
|
37
|
|
|
|
|
38
|
|
|
// Specify the filisystem from which to erase |
|
39
|
|
|
$fileSystem = $params[1]; |
|
40
|
|
|
|
|
41
|
|
|
$detachedImages = FileSystem::find([ |
|
42
|
|
|
'conditions' => 'users_id = 0 and is_deleted = 0' |
|
43
|
|
|
]); |
|
44
|
|
|
|
|
45
|
|
|
if ($fullDelete == 0 && is_object($detachedImages)) { |
|
46
|
|
|
foreach ($detachedImages as $detachedImage) { |
|
47
|
|
|
//Get the file name |
|
48
|
|
|
$filePathArray = explode('/', $detachedImage->path); |
|
49
|
|
|
$fileName = end($filePathArray); |
|
50
|
|
|
|
|
51
|
|
|
//Soft Delete file |
|
52
|
|
|
$detachedImage->is_deleted = 1; |
|
53
|
|
|
|
|
54
|
|
|
if ($detachedImage->update()) { |
|
55
|
|
|
$this->di->get('filesystem', $fileSystem)->delete($fileName); |
|
56
|
|
|
echo 'Image with id ' . $detachedImage->id . " has been soft deleted \n"; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
} else { |
|
60
|
|
|
foreach ($detachedImages as $detachedImage) { |
|
61
|
|
|
//Get the file name |
|
62
|
|
|
$filePathArray = explode('/', $detachedImage->path); |
|
63
|
|
|
$fileName = end($filePathArray); |
|
64
|
|
|
|
|
65
|
|
|
echo 'Image with id ' . $detachedImage->id . " has been fully deleted \n"; |
|
66
|
|
|
$detachedImage->delete(); |
|
67
|
|
|
$this->di->get('filesystem', $fileSystem)->delete($fileName); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths