Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/storage/DifferentialRevision.php
| <?php | <?php | ||||
| final class DifferentialRevision extends DifferentialDAO | final class DifferentialRevision extends DifferentialDAO | ||||
| implements | implements | ||||
| PhabricatorTokenReceiverInterface, | PhabricatorTokenReceiverInterface, | ||||
| PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
| PhabricatorExtendedPolicyInterface, | |||||
| PhabricatorFlaggableInterface, | PhabricatorFlaggableInterface, | ||||
| PhrequentTrackableInterface, | PhrequentTrackableInterface, | ||||
| HarbormasterBuildableInterface, | HarbormasterBuildableInterface, | ||||
| PhabricatorSubscribableInterface, | PhabricatorSubscribableInterface, | ||||
| PhabricatorCustomFieldInterface, | PhabricatorCustomFieldInterface, | ||||
| PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
| PhabricatorMentionableInterface, | PhabricatorMentionableInterface, | ||||
| PhabricatorDestructibleInterface, | PhabricatorDestructibleInterface, | ||||
| ▲ Show 20 Lines • Show All 260 Lines • ▼ Show 20 Lines | public function getHashes() { | ||||
| return $this->assertAttached($this->hashes); | return $this->assertAttached($this->hashes); | ||||
| } | } | ||||
| public function attachHashes(array $hashes) { | public function attachHashes(array $hashes) { | ||||
| $this->hashes = $hashes; | $this->hashes = $hashes; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| /* -( PhabricatorPolicyInterface )----------------------------------------- */ | |||||
| public function getCapabilities() { | public function getCapabilities() { | ||||
| return array( | return array( | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
| ); | ); | ||||
| } | } | ||||
| public function getPolicy($capability) { | public function getPolicy($capability) { | ||||
| Show All 30 Lines | switch ($capability) { | ||||
| 'If a revision belongs to a repository, other users must be able '. | 'If a revision belongs to a repository, other users must be able '. | ||||
| 'to view the repository in order to view the revision.'); | 'to view the repository in order to view the revision.'); | ||||
| break; | break; | ||||
| } | } | ||||
| return $description; | return $description; | ||||
| } | } | ||||
| /* -( PhabricatorExtendedPolicyInterface )--------------------------------- */ | |||||
| public function getExtendedPolicy($capability, PhabricatorUser $viewer) { | |||||
| $extended = array(); | |||||
| switch ($capability) { | |||||
| case PhabricatorPolicyCapability::CAN_VIEW: | |||||
| // NOTE: In Differential, an automatic capability on a revision (being | |||||
| // an author) is sufficient to view it, even if you can not see the | |||||
| // repository the revision belongs to. We can bail out early in this | |||||
| // case. | |||||
| if ($this->hasAutomaticCapability($capability, $viewer)) { | |||||
| break; | |||||
| } | |||||
| $repository_phid = $this->getRepositoryPHID(); | |||||
| $repository = $this->getRepository(); | |||||
| // Try to use the object if we have it, since it will save us some | |||||
| // data fetching later on. In some cases, we might not have it. | |||||
| $repository_ref = nonempty($repository, $repository_phid); | |||||
| if ($repository_ref) { | |||||
| $extended[] = array( | |||||
| $repository_ref, | |||||
| PhabricatorPolicyCapability::CAN_VIEW, | |||||
| ); | |||||
| } | |||||
| break; | |||||
| } | |||||
| return $extended; | |||||
| } | |||||
| /* -( PhabricatorTokenReceiverInterface )---------------------------------- */ | |||||
| public function getUsersToNotifyOfTokenGiven() { | public function getUsersToNotifyOfTokenGiven() { | ||||
| return array( | return array( | ||||
| $this->getAuthorPHID(), | $this->getAuthorPHID(), | ||||
| ); | ); | ||||
| } | } | ||||
| public function getReviewerStatus() { | public function getReviewerStatus() { | ||||
| return $this->assertAttached($this->reviewerStatus); | return $this->assertAttached($this->reviewerStatus); | ||||
| ▲ Show 20 Lines • Show All 245 Lines • Show Last 20 Lines | |||||