Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / badges / storage / PhabricatorBadgesAward.php
blob3f1472258f8e467102a7dcc7b09e2a0d8024a62e
1 <?php
3 final class PhabricatorBadgesAward extends PhabricatorBadgesDAO
4 implements
5 PhabricatorDestructibleInterface,
6 PhabricatorPolicyInterface {
8 protected $badgePHID;
9 protected $recipientPHID;
10 protected $awarderPHID;
12 private $badge = self::ATTACHABLE;
14 public static function initializeNewBadgesAward(
15 PhabricatorUser $actor,
16 PhabricatorBadgesBadge $badge,
17 $recipient_phid) {
18 return id(new self())
19 ->setRecipientPHID($recipient_phid)
20 ->setBadgePHID($badge->getPHID())
21 ->setAwarderPHID($actor->getPHID())
22 ->attachBadge($badge);
25 protected function getConfiguration() {
26 return array(
27 self::CONFIG_KEY_SCHEMA => array(
28 'key_badge' => array(
29 'columns' => array('badgePHID', 'recipientPHID'),
30 'unique' => true,
32 'key_recipient' => array(
33 'columns' => array('recipientPHID'),
36 ) + parent::getConfiguration();
39 public function attachBadge(PhabricatorBadgesBadge $badge) {
40 $this->badge = $badge;
41 return $this;
44 public function getBadge() {
45 return $this->assertAttached($this->badge);
49 /* -( PhabricatorDestructibleInterface )----------------------------------- */
52 public function destroyObjectPermanently(
53 PhabricatorDestructionEngine $engine) {
55 $this->openTransaction();
56 $this->delete();
57 $this->saveTransaction();
61 /* -( PhabricatorPolicyInterface )----------------------------------------- */
64 public function getCapabilities() {
65 return array(
66 PhabricatorPolicyCapability::CAN_VIEW,
67 PhabricatorPolicyCapability::CAN_EDIT,
71 public function getPolicy($capability) {
72 return $this->getBadge()->getPolicy($capability);
75 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
76 return false;