3 final class PhabricatorBadgesAward
extends PhabricatorBadgesDAO
5 PhabricatorDestructibleInterface
,
6 PhabricatorPolicyInterface
{
9 protected $recipientPHID;
10 protected $awarderPHID;
12 private $badge = self
::ATTACHABLE
;
14 public static function initializeNewBadgesAward(
15 PhabricatorUser
$actor,
16 PhabricatorBadgesBadge
$badge,
19 ->setRecipientPHID($recipient_phid)
20 ->setBadgePHID($badge->getPHID())
21 ->setAwarderPHID($actor->getPHID())
22 ->attachBadge($badge);
25 protected function getConfiguration() {
27 self
::CONFIG_KEY_SCHEMA
=> array(
29 'columns' => array('badgePHID', 'recipientPHID'),
32 'key_recipient' => array(
33 'columns' => array('recipientPHID'),
36 ) + parent
::getConfiguration();
39 public function attachBadge(PhabricatorBadgesBadge
$badge) {
40 $this->badge
= $badge;
44 public function getBadge() {
45 return $this->assertAttached($this->badge
);
49 /* -( PhabricatorDestructibleInterface )----------------------------------- */
52 public function destroyObjectPermanently(
53 PhabricatorDestructionEngine
$engine) {
55 $this->openTransaction();
57 $this->saveTransaction();
61 /* -( PhabricatorPolicyInterface )----------------------------------------- */
64 public function getCapabilities() {
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) {