Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/files/worker/FileDeletionWorker.php
12242 views
1
<?php
2
3
final class FileDeletionWorker extends PhabricatorWorker {
4
5
private function loadFile() {
6
$phid = idx($this->getTaskData(), 'objectPHID');
7
if (!$phid) {
8
throw new PhabricatorWorkerPermanentFailureException(
9
pht('No "%s" in task data.', 'objectPHID'));
10
}
11
12
$file = id(new PhabricatorFileQuery())
13
->setViewer(PhabricatorUser::getOmnipotentUser())
14
->withPHIDs(array($phid))
15
->executeOne();
16
17
if (!$file) {
18
throw new PhabricatorWorkerPermanentFailureException(
19
pht('File "%s" does not exist.', $phid));
20
}
21
22
return $file;
23
}
24
25
protected function doWork() {
26
$file = $this->loadFile();
27
$engine = new PhabricatorDestructionEngine();
28
$engine->destroyObject($file);
29
}
30
31
}
32
33