Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/files/storage/PhabricatorFileExternalRequest.php
12242 views
1
<?php
2
3
final class PhabricatorFileExternalRequest extends PhabricatorFileDAO
4
implements
5
PhabricatorDestructibleInterface {
6
7
protected $uri;
8
protected $uriIndex;
9
protected $ttl;
10
protected $filePHID;
11
protected $isSuccessful;
12
protected $responseMessage;
13
14
protected function getConfiguration() {
15
return array(
16
self::CONFIG_COLUMN_SCHEMA => array(
17
'uri' => 'text',
18
'uriIndex' => 'bytes12',
19
'ttl' => 'epoch',
20
'filePHID' => 'phid?',
21
'isSuccessful' => 'bool',
22
'responseMessage' => 'text?',
23
),
24
self::CONFIG_KEY_SCHEMA => array(
25
'key_uriindex' => array(
26
'columns' => array('uriIndex'),
27
'unique' => true,
28
),
29
'key_ttl' => array(
30
'columns' => array('ttl'),
31
),
32
'key_file' => array(
33
'columns' => array('filePHID'),
34
),
35
),
36
) + parent::getConfiguration();
37
}
38
39
public function save() {
40
$hash = PhabricatorHash::digestForIndex($this->getURI());
41
$this->setURIIndex($hash);
42
return parent::save();
43
}
44
45
/* -( PhabricatorDestructibleInterface )----------------------------------- */
46
47
public function destroyObjectPermanently(
48
PhabricatorDestructionEngine $engine) {
49
50
$file_phid = $this->getFilePHID();
51
if ($file_phid) {
52
$file = id(new PhabricatorFileQuery())
53
->setViewer($engine->getViewer())
54
->withPHIDs(array($file_phid))
55
->executeOne();
56
if ($file) {
57
$engine->destroyObject($file);
58
}
59
}
60
$this->delete();
61
}
62
63
}
64
65