You are here

class ComplexLcaResolver in Multiversion 8

Same name and namespace in other branches
  1. 8.2 src/Entity/Index/ComplexLcaResolver.php \Drupal\Multiversion\Entity\Index\ComplexLcaResolver

Hierarchy

Expanded class hierarchy of ComplexLcaResolver

File

src/Entity/Index/ComplexLcaResolver.php, line 10

Namespace

Drupal\Multiversion\Entity\Index
View source
class ComplexLcaResolver implements ConflictAncestorResolverInterface {

  /**
   * {@inheritdoc}
   */
  public function applies() {
    return TRUE;
  }

  /**
   * Find the lowest common parent of two revisions from given graph.
   *
   * @param RevisionableInterface $revision1
   * @param RevisionableInterface $revision2
   * @param Graph $graph
   *
   * @return array
   *   Returns an array of vertices or an empty array.
   */
  public function resolve(RevisionableInterface $revision1, RevisionableInterface $revision2, Graph $graph = NULL) {
    $lca = new LowestCommonAncestor($graph);
    $vertices = $graph
      ->getVertices()
      ->getMap();
    return $lca
      ->find($vertices[$revision1->_rev->value], $vertices[$revision2->_rev->value]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ComplexLcaResolver::applies public function Overrides ConflictAncestorResolverInterface::applies
ComplexLcaResolver::resolve public function Find the lowest common parent of two revisions from given graph. Overrides ConflictAncestorResolverInterface::resolve