Changeset View
Changeset View
Standalone View
Standalone View
src/applications/badges/application/PhabricatorBadgesApplication.php
- This file was added.
<?php | |||||
final class PhabricatorBadgesApplication extends PhabricatorApplication { | |||||
public function getName() { | |||||
return pht('Badges'); | |||||
} | |||||
public function getBaseURI() { | |||||
return '/badges/'; | |||||
} | |||||
public function getShortDescription() { | |||||
return pht('Achievements and Notority'); | |||||
} | |||||
public function getFontIcon() { | |||||
return 'fa-trophy'; | |||||
} | |||||
public function getFlavorText() { | |||||
return pht('Build self esteem through gamification.'); | |||||
} | |||||
public function getApplicationGroup() { | |||||
return self::GROUP_UTILITIES; | |||||
} | |||||
public function canUninstall() { | |||||
return true; | |||||
} | |||||
public function isPrototype() { | |||||
return true; | |||||
} | |||||
public function getRoutes() { | |||||
return array( | |||||
'/badges/' => array( | |||||
'(?:query/(?P<queryKey>[^/]+)/)?' | |||||
=> 'PhabricatorBadgesListController', | |||||
'create/' | |||||
=> 'PhabricatorBadgesEditController', | |||||
'edit/(?:(?P<id>\d+)/)?' | |||||
=> 'PhabricatorBadgesEditController', | |||||
'view/(?:(?P<id>\d+)/)?' | |||||
=> 'PhabricatorBadgesViewController', | |||||
'icon/(?P<id>[1-9]\d*)/' | |||||
=> 'PhabricatorBadgesEditIconController', | |||||
'icon/' | |||||
=> 'PhabricatorBadgesEditIconController', | |||||
'recipients/(?P<id>[1-9]\d*)/' | |||||
=> 'PhabricatorBadgesEditRecipientsController', | |||||
'recipients/(?P<id>[1-9]\d*)/remove/' | |||||
=> 'PhabricatorBadgesRemoveRecipientsController', | |||||
), | |||||
); | |||||
} | |||||
protected function getCustomCapabilities() { | |||||
return array( | |||||
PhabricatorBadgesCreateCapability::CAPABILITY => array( | |||||
'default' => PhabricatorPolicies::POLICY_ADMIN, | |||||
'caption' => pht('Default create policy for badges.'), | |||||
), | |||||
PhabricatorBadgesDefaultEditCapability::CAPABILITY => array( | |||||
epriestley: Oh, sorry -- this one //shouldn't// have a 'template'.
The idea is the policies which act as… | |||||
'default' => PhabricatorPolicies::POLICY_ADMIN, | |||||
'caption' => pht('Default edit policy for badges.'), | |||||
'template' => PhabricatorBadgesPHIDType::TYPECONST, | |||||
), | |||||
Done Inline ActionsThese should have a 'template' property now I think, pointing at the PHID type. epriestley: These should have a `'template'` property now I think, pointing at the PHID type. | |||||
PhabricatorBadgesDefaultViewCapability::CAPABILITY => array( | |||||
'caption' => pht('Default view policy for badges.'), | |||||
'template' => PhabricatorBadgesPHIDType::TYPECONST, | |||||
), | |||||
); | |||||
} | |||||
} |
Oh, sorry -- this one shouldn't have a 'template'.
The idea is the policies which act as object defaults (e.g., "default view", "default edit") get a template parameter, which tells the rest of the system that object-specific policies for that object type are appropriate values. In Applications → Badges → Help/Options → Edit Policies, object policies will show up in the dropdowns and be selectable.
For example, in the future, we might define a custom object policy like "Badge Author", and make it the default edit policy. We do something similar in Passphrase today. The "template" parameter tells the system that object-specific policies (like "Room Members" in Conpherence, "Task Author" in Maniphest, "Credential Author" in Passphrase, etc) are appropriate.
It would make sense to select "Badge Author" as the "Default Edit Policy", and also make sense (from a technical point of view, at least -- maybe not actually be useful) to select "Badge Author" as the "Default View Policy".
However, it doesn't make sense to select "Badge Author" as the "can create" policy, because the "can create" policy is evaluated before a badge is created, so there's no badge yet and also no badge author (the object the policy is evaluated against will be the Application, not a Badge).