Page MenuHomePhorge

HeraldRuleIndexEngineExtension.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

HeraldRuleIndexEngineExtension.php

<?php
final class HeraldRuleIndexEngineExtension
extends PhabricatorEdgeIndexEngineExtension {
const EXTENSIONKEY = 'herald.actions';
public function getExtensionName() {
return pht('Herald Actions');
}
public function shouldIndexObject($object) {
if (!($object instanceof HeraldRule)) {
return false;
}
return true;
}
protected function getIndexEdgeType() {
return HeraldRuleActionAffectsObjectEdgeType::EDGECONST;
}
protected function getIndexDestinationPHIDs($object) {
$rule = $object;
$viewer = $this->getViewer();
$rule = id(new HeraldRuleQuery())
->setViewer($viewer)
->withIDs(array($rule->getID()))
->needConditionsAndActions(true)
->executeOne();
if (!$rule) {
return array();
}
$phids = array();
$fields = HeraldField::getAllFields();
foreach ($rule->getConditions() as $condition_record) {
$field = idx($fields, $condition_record->getFieldName());
if (!$field) {
continue;
}
$affected_phids = $field->getPHIDsAffectedByCondition($condition_record);
foreach ($affected_phids as $phid) {
$phids[] = $phid;
}
}
$actions = HeraldAction::getAllActions();
foreach ($rule->getActions() as $action_record) {
$action = idx($actions, $action_record->getAction());
if (!$action) {
continue;
}
foreach ($action->getPHIDsAffectedByAction($action_record) as $phid) {
$phids[] = $phid;
}
}
$phids = array_fuse($phids);
return array_keys($phids);
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, May 12, 10:36 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
121272
Default Alt Text
HeraldRuleIndexEngineExtension.php (1 KB)

Event Timeline