public function addEdge($src, $type, $dst, $options)
Add a new edge (possibly also adding its inverse). Changes take effect when you call save(). If the edge already exists, it will not be overwritten, but if data is attached to the edge it will be updated. Removals queued with removeEdge() are executed before adds, so the effect of removing and adding the same edge is to overwrite any existing edge.
The $options parameter accepts these values:
- data Optional, data to write onto the edge.
- inverse_data Optional, data to write on the inverse edge. If not provided, data will be written.
phid | $src | Source object PHID. |
const | $type | Edge type constant. |
phid | $dst | Destination object PHID. |
map | $options | Options map (see documentation). |
this |
public function removeEdge($src, $type, $dst)
Remove an edge (possibly also removing its inverse). Changes take effect when you call save(). If an edge does not exist, the removal will be ignored. Edges are added after edges are removed, so the effect of a remove plus an add is to overwrite.
phid | $src | Source object PHID. |
const | $type | Edge type constant. |
phid | $dst | Destination object PHID. |
this |
public function save()
Apply edge additions and removals queued by addEdge() and removeEdge(). Note that transactions are opened, all additions and removals are executed, and then transactions are saved. Thus, in some cases it may be slightly more efficient to perform multiple edit operations (e.g., adds followed by removals) if their outcomes are not dependent, since transactions will not be held open as long.
this |
private function buildEdgeSpecs($src, $type, $dst, $options)
Build the specification for an edge operation, and possibly build its inverse as well.
$src | ||
$type | ||
$dst | ||
array | $options |
wild |
private function writeEdgeData()
Write edge data.
wild |
private function executeAdds()
Add queued edges.
wild |
private function executeRemoves()
Remove queued edges.
wild |
private function saveTransactions()
Save open transactions.
wild |
private function killTransactions()
wild |
private function getPreventCyclesEdgeTypes()
Get a list of all edge types which are being added, and which we should prevent cycles on.
list<const> | List of edge types which should have cycles prevented. |
private function detectCycles($phids, $edge_type)
Detect graph cycles of a given edge type. If the edit introduces a cycle, a PhabricatorEdgeCycleException is thrown with details.
array | $phids | |
$edge_type |
void |