forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorFileExternalRequest.php
63 lines (55 loc) · 1.53 KB
/
PhabricatorFileExternalRequest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
final class PhabricatorFileExternalRequest extends PhabricatorFileDAO
implements
PhabricatorDestructibleInterface {
protected $uri;
protected $uriIndex;
protected $ttl;
protected $filePHID;
protected $isSuccessful;
protected $responseMessage;
protected function getConfiguration() {
return array(
self::CONFIG_COLUMN_SCHEMA => array(
'uri' => 'text',
'uriIndex' => 'bytes12',
'ttl' => 'epoch',
'filePHID' => 'phid?',
'isSuccessful' => 'bool',
'responseMessage' => 'text?',
),
self::CONFIG_KEY_SCHEMA => array(
'key_uriindex' => array(
'columns' => array('uriIndex'),
'unique' => true,
),
'key_ttl' => array(
'columns' => array('ttl'),
),
'key_file' => array(
'columns' => array('filePHID'),
),
),
) + parent::getConfiguration();
}
public function save() {
$hash = PhabricatorHash::digestForIndex($this->getURI());
$this->setURIIndex($hash);
return parent::save();
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$file_phid = $this->getFilePHID();
if ($file_phid) {
$file = id(new PhabricatorFileQuery())
->setViewer($engine->getViewer())
->withPHIDs(array($file_phid))
->executeOne();
if ($file) {
$engine->destroyObject($file);
}
}
$this->delete();
}
}