Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/storage/PhabricatorFile.php
Show First 20 Lines • Show All 1,416 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
public function attachToObject($phid) { | public function attachToObject($phid) { | ||||
$edge_type = PhabricatorObjectHasFileEdgeType::EDGECONST; | $edge_type = PhabricatorObjectHasFileEdgeType::EDGECONST; | ||||
id(new PhabricatorEdgeEditor()) | id(new PhabricatorEdgeEditor()) | ||||
->addEdge($phid, $edge_type, $this->getPHID()) | ->addEdge($phid, $edge_type, $this->getPHID()) | ||||
->save(); | ->save(); | ||||
$attachment_table = new PhabricatorFileAttachment(); | |||||
$attachment_conn = $attachment_table->establishConnection('w'); | |||||
queryfx( | |||||
$attachment_conn, | |||||
'INSERT INTO %R (objectPHID, filePHID, attachmentMode, | |||||
attacherPHID, dateCreated, dateModified) | |||||
VALUES (%s, %s, %s, %ns, %d, %d) | |||||
ON DUPLICATE KEY UPDATE | |||||
attachmentMode = VALUES(attachmentMode), | |||||
attacherPHID = VALUES(attacherPHID), | |||||
dateModified = VALUES(dateModified)', | |||||
$attachment_table, | |||||
$phid, | |||||
$this->getPHID(), | |||||
PhabricatorFileAttachment::MODE_ATTACH, | |||||
null, | |||||
PhabricatorTime::getNow(), | |||||
PhabricatorTime::getNow()); | |||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Configure a newly created file object according to specified parameters. | * Configure a newly created file object according to specified parameters. | ||||
* | * | ||||
* This method is called both when creating a file from fresh data, and | * This method is called both when creating a file from fresh data, and | ||||
▲ Show 20 Lines • Show All 318 Lines • Show Last 20 Lines |