Changeset View
Changeset View
Standalone View
Standalone View
src/applications/herald/query/HeraldRuleQuery.php
<?php | <?php | ||||
final class HeraldRuleQuery extends PhabricatorCursorPagedPolicyAwareQuery { | final class HeraldRuleQuery extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
private $ids; | private $ids; | ||||
private $phids; | private $phids; | ||||
private $authorPHIDs; | private $authorPHIDs; | ||||
private $ruleTypes; | private $ruleTypes; | ||||
private $contentTypes; | private $contentTypes; | ||||
private $disabled; | private $disabled; | ||||
private $active; | private $active; | ||||
private $datasourceQuery; | private $datasourceQuery; | ||||
private $triggerObjectPHIDs; | private $triggerObjectPHIDs; | ||||
private $affectedObjectPHIDs; | |||||
private $needConditionsAndActions; | private $needConditionsAndActions; | ||||
private $needAppliedToPHIDs; | private $needAppliedToPHIDs; | ||||
private $needValidateAuthors; | private $needValidateAuthors; | ||||
public function withIDs(array $ids) { | public function withIDs(array $ids) { | ||||
$this->ids = $ids; | $this->ids = $ids; | ||||
return $this; | return $this; | ||||
Show All 34 Lines | public function withDatasourceQuery($query) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withTriggerObjectPHIDs(array $phids) { | public function withTriggerObjectPHIDs(array $phids) { | ||||
$this->triggerObjectPHIDs = $phids; | $this->triggerObjectPHIDs = $phids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withAffectedObjectPHIDs(array $phids) { | |||||
$this->affectedObjectPHIDs = $phids; | |||||
return $this; | |||||
} | |||||
public function needConditionsAndActions($need) { | public function needConditionsAndActions($need) { | ||||
$this->needConditionsAndActions = $need; | $this->needConditionsAndActions = $need; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function needAppliedToPHIDs(array $phids) { | public function needAppliedToPHIDs(array $phids) { | ||||
$this->needAppliedToPHIDs = $phids; | $this->needAppliedToPHIDs = $phids; | ||||
return $this; | return $this; | ||||
▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
if ($this->triggerObjectPHIDs !== null) { | if ($this->triggerObjectPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'rule.triggerObjectPHID IN (%Ls)', | 'rule.triggerObjectPHID IN (%Ls)', | ||||
$this->triggerObjectPHIDs); | $this->triggerObjectPHIDs); | ||||
} | } | ||||
if ($this->affectedObjectPHIDs !== null) { | |||||
$where[] = qsprintf( | |||||
$conn, | |||||
'edge_affects.dst IN (%Ls)', | |||||
$this->affectedObjectPHIDs); | |||||
} | |||||
return $where; | return $where; | ||||
} | } | ||||
protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { | |||||
$joins = parent::buildJoinClauseParts($conn); | |||||
if ($this->affectedObjectPHIDs !== null) { | |||||
$joins[] = qsprintf( | |||||
$conn, | |||||
'JOIN %T edge_affects ON rule.phid = edge_affects.src | |||||
AND edge_affects.type = %d', | |||||
PhabricatorEdgeConfig::TABLE_NAME_EDGE, | |||||
HeraldRuleActionAffectsObjectEdgeType::EDGECONST); | |||||
} | |||||
return $joins; | |||||
} | |||||
private function validateRuleAuthors(array $rules) { | private function validateRuleAuthors(array $rules) { | ||||
// "Global" and "Object" rules always have valid authors. | // "Global" and "Object" rules always have valid authors. | ||||
foreach ($rules as $key => $rule) { | foreach ($rules as $key => $rule) { | ||||
if ($rule->isGlobalRule() || $rule->isObjectRule()) { | if ($rule->isGlobalRule() || $rule->isObjectRule()) { | ||||
$rule->attachValidAuthor(true); | $rule->attachValidAuthor(true); | ||||
unset($rules[$key]); | unset($rules[$key]); | ||||
continue; | continue; | ||||
} | } | ||||
Show All 39 Lines |