Changeset View
Changeset View
Standalone View
Standalone View
src/applications/herald/controller/HeraldRuleController.php
Show First 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | final class HeraldRuleController extends HeraldController { | ||||
} | } | ||||
private function setupEditorBehavior( | private function setupEditorBehavior( | ||||
HeraldRule $rule, | HeraldRule $rule, | ||||
array $handles, | array $handles, | ||||
HeraldAdapter $adapter) { | HeraldAdapter $adapter) { | ||||
$all_rules = $this->loadRulesThisRuleMayDependUpon($rule); | $all_rules = $this->loadRulesThisRuleMayDependUpon($rule); | ||||
$all_rules = mpull($all_rules, 'getName', 'getPHID'); | $all_rules = msortv($all_rules, 'getEditorSortVector'); | ||||
asort($all_rules); | $all_rules = mpull($all_rules, 'getEditorDisplayName', 'getPHID'); | ||||
$all_fields = $adapter->getFieldNameMap(); | $all_fields = $adapter->getFieldNameMap(); | ||||
$all_conditions = $adapter->getConditionNameMap(); | $all_conditions = $adapter->getConditionNameMap(); | ||||
$all_actions = $adapter->getActionNameMap($rule->getRuleType()); | $all_actions = $adapter->getActionNameMap($rule->getRuleType()); | ||||
$fields = $adapter->getFields(); | $fields = $adapter->getFields(); | ||||
$field_map = array_select_keys($all_fields, $fields); | $field_map = array_select_keys($all_fields, $fields); | ||||
▲ Show 20 Lines • Show All 252 Lines • ▼ Show 20 Lines | if ($rule->isPersonalRule()) { | ||||
$all_rules += id(new HeraldRuleQuery()) | $all_rules += id(new HeraldRuleQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withRuleTypes(array(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL)) | ->withRuleTypes(array(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL)) | ||||
->withContentTypes(array($rule->getContentType())) | ->withContentTypes(array($rule->getContentType())) | ||||
->withAuthorPHIDs(array($rule->getAuthorPHID())) | ->withAuthorPHIDs(array($rule->getAuthorPHID())) | ||||
->execute(); | ->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. | // A rule can not depend upon itself. | ||||
unset($all_rules[$rule->getID()]); | unset($all_rules[$rule->getID()]); | ||||
return $all_rules; | return $all_rules; | ||||
} | } | ||||
private function getFieldGroups(HeraldAdapter $adapter, array $field_map) { | private function getFieldGroups(HeraldAdapter $adapter, array $field_map) { | ||||
$group_map = array(); | $group_map = array(); | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |