3 abstract class PhabricatorEdgeIndexEngineExtension
4 extends PhabricatorIndexEngineExtension
{
6 abstract protected function getIndexEdgeType();
7 abstract protected function getIndexDestinationPHIDs($object);
9 final public function indexObject(
10 PhabricatorIndexEngine
$engine,
13 $edge_type = $this->getIndexEdgeType();
15 $old_edges = PhabricatorEdgeQuery
::loadDestinationPHIDs(
18 $old_edges = array_fuse($old_edges);
20 $new_edges = $this->getIndexDestinationPHIDs($object);
21 $new_edges = array_fuse($new_edges);
23 $add_edges = array_diff_key($new_edges, $old_edges);
24 $rem_edges = array_diff_key($old_edges, $new_edges);
26 if (!$add_edges && !$rem_edges) {
30 $editor = new PhabricatorEdgeEditor();
32 foreach ($add_edges as $phid) {
33 $editor->addEdge($object->getPHID(), $edge_type, $phid);
36 foreach ($rem_edges as $phid) {
37 $editor->removeEdge($object->getPHID(), $edge_type, $phid);
43 final public function getIndexVersion($object) {
44 $phids = $this->getIndexDestinationPHIDs($object);
46 $phids = implode(':', $phids);
47 return PhabricatorHash
::digestForIndex($phids);