Herald rule match project and its milestones


#1

Is there a way to have a global herald rule for maniphest tasks with project tag condition to also match tasks in milestones of the selected projects?


#2

Workaround by modifying HeraldProjectsField. This is enough in my use case for now:

<?php

final class HeraldProjectsField extends HeraldField {
...
  public function getHeraldFieldValue($object) {
    $projectPHIDs = PhabricatorEdgeQuery::loadDestinationPHIDs(
      $object->getPHID(),
      PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);

    // Include parent projects for milestone projects tagged to the task
    $projects = id(new PhabricatorProjectQuery())
      ->setViewer(PhabricatorUser::getOmnipotentUser())
      ->withPHIDs($projectPHIDs)
      ->execute();

    foreach ($projects as $project) {
      if ($project->isMilestone()) {
        $projectPHIDs[] = $project
          ->getParentProject()
          ->getPHID();
      }
    }

    return $projectPHIDs;
  }
...
}

closed #3