3 final class PhabricatorProjectTriggerPlaySoundRule
4 extends PhabricatorProjectTriggerRule
{
6 const TRIGGERTYPE
= 'sound';
8 public function getSelectControlName() {
9 return pht('Play sound');
12 protected function assertValidRuleRecordFormat($value) {
13 if (!is_string($value)) {
16 'Status rule value should be a string, but is not (value is "%s").',
17 phutil_describe_type($value)));
21 protected function assertValidRuleRecordValue($value) {
22 $map = self
::getSoundMap();
23 if (!isset($map[$value])) {
26 'Sound ("%s") is not a valid sound.',
31 protected function newDropTransactions($object, $value) {
35 protected function newDropEffects($value) {
36 $sound_icon = 'fa-volume-up';
37 $sound_color = 'blue';
38 $sound_name = self
::getSoundName($value);
42 phutil_tag('strong', array(), $sound_name));
46 ->setIcon($sound_icon)
47 ->setColor($sound_color)
48 ->setContent($content),
52 protected function getDefaultValue() {
53 return head_key(self
::getSoundMap());
56 protected function getPHUIXControlType() {
60 protected function getPHUIXControlSpecification() {
61 $map = self
::getSoundMap();
62 $map = ipull($map, 'name');
66 'order' => array_keys($map),
70 public function getRuleViewLabel() {
71 return pht('Play Sound');
74 public function getRuleViewDescription($value) {
75 $sound_name = self
::getSoundName($value);
79 phutil_tag('strong', array(), $sound_name));
82 public function getRuleViewIcon($value) {
83 $sound_icon = 'fa-volume-up';
84 $sound_color = 'blue';
86 return id(new PHUIIconView())
87 ->setIcon($sound_icon, $sound_color);
90 private static function getSoundName($value) {
91 $map = self
::getSoundMap();
92 $spec = idx($map, $value, array());
93 return idx($spec, 'name', $value);
96 private static function getSoundMap() {
99 'name' => pht('Bing'),
100 'uri' => celerity_get_resource_uri('/rsrc/audio/basic/bing.mp3'),
103 'name' => pht('Glass'),
104 'uri' => celerity_get_resource_uri('/rsrc/audio/basic/ting.mp3'),
109 public function getSoundEffects() {
110 $value = $this->getValue();
112 $map = self
::getSoundMap();
113 $spec = idx($map, $value, array());
116 if (isset($spec['uri'])) {
117 $uris[] = $spec['uri'];