Differential D11116 Diff 26807 src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | public function save() { | ||||
} | } | ||||
$actor = $this->requireActor(); | $actor = $this->requireActor(); | ||||
$src = $this->object->getPHID(); | $src = $this->object->getPHID(); | ||||
if ($this->implicitSubscribePHIDs) { | if ($this->implicitSubscribePHIDs) { | ||||
$unsub = PhabricatorEdgeQuery::loadDestinationPHIDs( | $unsub = PhabricatorEdgeQuery::loadDestinationPHIDs( | ||||
$src, | $src, | ||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER); | PhabricatorObjectHasUnsubscriberEdgeType::EDGECONST); | ||||
$unsub = array_fill_keys($unsub, true); | $unsub = array_fill_keys($unsub, true); | ||||
$this->implicitSubscribePHIDs = array_diff_key( | $this->implicitSubscribePHIDs = array_diff_key( | ||||
$this->implicitSubscribePHIDs, | $this->implicitSubscribePHIDs, | ||||
$unsub); | $unsub); | ||||
} | } | ||||
$add = $this->implicitSubscribePHIDs + $this->explicitSubscribePHIDs; | $add = $this->implicitSubscribePHIDs + $this->explicitSubscribePHIDs; | ||||
$del = $this->unsubscribePHIDs; | $del = $this->unsubscribePHIDs; | ||||
// If a PHID is marked for both subscription and unsubscription, treat | // If a PHID is marked for both subscription and unsubscription, treat | ||||
// unsubscription as the stronger action. | // unsubscription as the stronger action. | ||||
$add = array_diff_key($add, $del); | $add = array_diff_key($add, $del); | ||||
if ($add || $del) { | if ($add || $del) { | ||||
$u_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER; | $u_type = PhabricatorObjectHasUnsubscriberEdgeType::EDGECONST; | ||||
$s_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_SUBSCRIBER; | $s_type = PhabricatorObjectHasSubscriberEdgeType::EDGECONST; | ||||
$editor = new PhabricatorEdgeEditor(); | $editor = new PhabricatorEdgeEditor(); | ||||
foreach ($add as $phid => $ignored) { | foreach ($add as $phid => $ignored) { | ||||
$editor->removeEdge($src, $u_type, $phid); | $editor->removeEdge($src, $u_type, $phid); | ||||
$editor->addEdge($src, $s_type, $phid); | $editor->addEdge($src, $s_type, $phid); | ||||
} | } | ||||
Show All 10 Lines |