Differential D8291 Diff 19730 src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
| Show First 20 Lines • Show All 984 Lines • ▼ Show 20 Lines | protected function getEdgeTransactionNewValue( | ||||
| $result = array(); | $result = array(); | ||||
| foreach ($old as $dst_phid => $edge) { | foreach ($old as $dst_phid => $edge) { | ||||
| if ($new_set !== null && empty($new_set[$dst_phid])) { | if ($new_set !== null && empty($new_set[$dst_phid])) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $result[$dst_phid] = $this->normalizeEdgeTransactionValue( | $result[$dst_phid] = $this->normalizeEdgeTransactionValue( | ||||
| $xaction, | $xaction, | ||||
| $edge); | $edge, | ||||
| $dst_phid); | |||||
| } | } | ||||
| if ($new_set !== null) { | if ($new_set !== null) { | ||||
| foreach ($new_set as $dst_phid => $edge) { | foreach ($new_set as $dst_phid => $edge) { | ||||
| $result[$dst_phid] = $this->normalizeEdgeTransactionValue( | $result[$dst_phid] = $this->normalizeEdgeTransactionValue( | ||||
| $xaction, | $xaction, | ||||
| $edge); | $edge, | ||||
| $dst_phid); | |||||
| } | } | ||||
| } | } | ||||
| foreach ($new_add as $dst_phid => $edge) { | foreach ($new_add as $dst_phid => $edge) { | ||||
| $result[$dst_phid] = $this->normalizeEdgeTransactionValue( | $result[$dst_phid] = $this->normalizeEdgeTransactionValue( | ||||
| $xaction, | $xaction, | ||||
| $edge); | $edge, | ||||
| $dst_phid); | |||||
| } | } | ||||
| foreach ($new_rem as $dst_phid => $edge) { | foreach ($new_rem as $dst_phid => $edge) { | ||||
| unset($result[$dst_phid]); | unset($result[$dst_phid]); | ||||
| } | } | ||||
| return $result; | return $result; | ||||
| } | } | ||||
| Show All 11 Lines | foreach ($list as $key => $item) { | ||||
| if (!is_array($item) && $item !== $key) { | if (!is_array($item) && $item !== $key) { | ||||
| throw new Exception( | throw new Exception( | ||||
| "Edge transactions must have PHIDs or edge specs as values ". | "Edge transactions must have PHIDs or edge specs as values ". | ||||
| "(found value '{$item}')."); | "(found value '{$item}')."); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| protected function normalizeEdgeTransactionValue( | private function normalizeEdgeTransactionValue( | ||||
| PhabricatorApplicationTransaction $xaction, | PhabricatorApplicationTransaction $xaction, | ||||
| $edge) { | $edge, | ||||
| $dst_phid) { | |||||
| if (!is_array($edge)) { | if (!is_array($edge)) { | ||||
| $edge = array( | if ($edge != $dst_phid) { | ||||
| 'dst' => $edge, | throw new Exception( | ||||
| ); | pht( | ||||
| 'Transaction edge data must either be the edge PHID or an edge '. | |||||
| 'specification dictionary.')); | |||||
| } | |||||
| $edge = array(); | |||||
| } else { | |||||
| foreach ($edge as $key => $value) { | |||||
| switch ($key) { | |||||
| case 'src': | |||||
| case 'dst': | |||||
| case 'type': | |||||
| case 'data': | |||||
| case 'dateCreated': | |||||
| case 'dateModified': | |||||
| case 'seq': | |||||
| case 'dataID': | |||||
| break; | |||||
| default: | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Transaction edge specification contains unexpected key '. | |||||
| '"%s".', | |||||
| $key)); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| $edge_type = $xaction->getMetadataValue('edge:type'); | $edge['dst'] = $dst_phid; | ||||
| $edge_type = $xaction->getMetadataValue('edge:type'); | |||||
| if (empty($edge['type'])) { | if (empty($edge['type'])) { | ||||
| $edge['type'] = $edge_type; | $edge['type'] = $edge_type; | ||||
| } else { | } else { | ||||
| if ($edge['type'] != $edge_type) { | if ($edge['type'] != $edge_type) { | ||||
| $this_type = $edge['type']; | $this_type = $edge['type']; | ||||
| throw new Exception( | throw new Exception( | ||||
| "Edge transaction includes edge of type '{$this_type}', but ". | "Edge transaction includes edge of type '{$this_type}', but ". | ||||
| "transaction is of type '{$edge_type}'. Each edge transaction must ". | "transaction is of type '{$edge_type}'. Each edge transaction must ". | ||||
| ▲ Show 20 Lines • Show All 712 Lines • Show Last 20 Lines | |||||