You are here

public function DiffEntityComparison::getRows in Diff 8

Prepare the table rows for #type 'table'.

Parameters

string $a: The source string to compare from.

string $b: The target string to compare to.

bool $show_header: Display diff context headers. For example, "Line x".

array $line_stats: Tracks line numbers across multiple calls to DiffFormatter.

Return value

array Array of rows usable with #type => 'table' returned by the core diff formatter when format a diff.

See also

\Drupal\Component\Diff\DiffFormatter::format

File

src/DiffEntityComparison.php, line 211

Class

DiffEntityComparison
Entity comparison service that prepares a diff of a pair of entities.

Namespace

Drupal\diff

Code

public function getRows($a, $b, $show_header = FALSE, array &$line_stats = NULL) {
  if (!isset($line_stats)) {
    $line_stats = array(
      'counter' => array(
        'x' => 0,
        'y' => 0,
      ),
      'offset' => array(
        'x' => 0,
        'y' => 0,
      ),
    );
  }

  // Header is the line counter.
  $this->diffFormatter->show_header = $show_header;
  $diff = new Diff($a, $b);
  return $this->diffFormatter
    ->format($diff);
}