private function buildPropertySectionView(HeraldRule $rule) { $viewer = $this->getRequest()->getUser(); $view = id(new PHUIPropertyListView())->setUser($viewer); $view->addProperty(pht('Rule Type'), idx(HeraldRuleTypeConfig::getRuleTypeMap(), $rule->getRuleType())); if ($rule->isPersonalRule()) { $view->addProperty(pht('Author'), $viewer->renderHandle($rule->getAuthorPHID())); } $adapter = HeraldAdapter::getAdapterForContentType($rule->getContentType()); if ($adapter) { $view->addProperty(pht('Applies To'), idx(HeraldAdapter::getEnabledAdapterMap($viewer), $rule->getContentType())); if ($rule->isObjectRule()) { $view->addProperty(pht('Trigger Object'), $viewer->renderHandle($rule->getTriggerObjectPHID())); } } return $view; }
/** * Load rules for the "Another Herald rule..." condition dropdown, which * allows one rule to depend upon the success or failure of another rule. */ private function loadRulesThisRuleMayDependUpon(HeraldRule $rule) { $viewer = $this->getRequest()->getUser(); // Any rule can depend on a global rule. $all_rules = id(new HeraldRuleQuery())->setViewer($viewer)->withRuleTypes(array(HeraldRuleTypeConfig::RULE_TYPE_GLOBAL))->withContentTypes(array($rule->getContentType()))->execute(); if ($rule->isObjectRule()) { // Object rules may depend on other rules for the same object. $all_rules += id(new HeraldRuleQuery())->setViewer($viewer)->withRuleTypes(array(HeraldRuleTypeConfig::RULE_TYPE_OBJECT))->withContentTypes(array($rule->getContentType()))->withTriggerObjectPHIDs(array($rule->getTriggerObjectPHID()))->execute(); } if ($rule->isPersonalRule()) { // Personal rules may depend upon your other personal rules. $all_rules += id(new HeraldRuleQuery())->setViewer($viewer)->withRuleTypes(array(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL))->withContentTypes(array($rule->getContentType()))->withAuthorPHIDs(array($rule->getAuthorPHID()))->execute(); } // mark disabled rules as disabled since they are not useful as such; // don't filter though to keep edit cases sane / expected foreach ($all_rules as $current_rule) { if ($current_rule->getIsDisabled()) { $current_rule->makeEphemeral(); $current_rule->setName($rule->getName() . ' ' . pht('(Disabled)')); } } // A rule can not depend upon itself. unset($all_rules[$rule->getID()]); return $all_rules; }