3 final class HeraldRuleListView
8 public function setRules(array $rules) {
9 assert_instances_of($rules, 'HeraldRule');
10 $this->rules
= $rules;
14 public function render() {
15 return $this->newObjectList();
18 public function newObjectList() {
19 $viewer = $this->getViewer();
20 $rules = $this->rules
;
22 $handles = $viewer->loadHandles(mpull($rules, 'getAuthorPHID'));
24 $content_type_map = HeraldAdapter
::getEnabledAdapterMap($viewer);
26 $list = id(new PHUIObjectItemListView())
28 foreach ($rules as $rule) {
29 $monogram = $rule->getMonogram();
31 $item = id(new PHUIObjectItemView())
32 ->setObjectName($monogram)
33 ->setHeader($rule->getName())
34 ->setHref($rule->getURI());
36 if ($rule->isPersonalRule()) {
37 $item->addIcon('fa-user', pht('Personal Rule'));
41 $handles[$rule->getAuthorPHID()]->renderLink()));
42 } else if ($rule->isObjectRule()) {
43 $item->addIcon('fa-briefcase', pht('Object Rule'));
45 $item->addIcon('fa-globe', pht('Global Rule'));
48 if ($rule->getIsDisabled()) {
49 $item->setDisabled(true);
50 $item->addIcon('fa-lock grey', pht('Disabled'));
51 } else if (!$rule->hasValidAuthor()) {
52 $item->setDisabled(true);
53 $item->addIcon('fa-user grey', pht('Author Not Active'));
56 $content_type_name = idx($content_type_map, $rule->getContentType());
57 $item->addAttribute(pht('Affects: %s', $content_type_name));
59 $list->addItem($item);