function DiffFormatter::_changed

Same name in this branch
  1. 9 core/lib/Drupal/Component/Diff/DiffFormatter.php \Drupal\Component\Diff\DiffFormatter::_changed()
Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Diff/DiffFormatter.php \Drupal\Core\Diff\DiffFormatter::_changed()
  2. 8.9.x core/lib/Drupal/Component/Diff/DiffFormatter.php \Drupal\Component\Diff\DiffFormatter::_changed()
  3. 10 core/lib/Drupal/Core/Diff/DiffFormatter.php \Drupal\Core\Diff\DiffFormatter::_changed()
  4. 10 core/lib/Drupal/Component/Diff/DiffFormatter.php \Drupal\Component\Diff\DiffFormatter::_changed()
  5. 11.x core/lib/Drupal/Core/Diff/DiffFormatter.php \Drupal\Core\Diff\DiffFormatter::_changed()
  6. 11.x core/lib/Drupal/Component/Diff/DiffFormatter.php \Drupal\Component\Diff\DiffFormatter::_changed()

Overrides DiffFormatter::_changed

File

core/lib/Drupal/Core/Diff/DiffFormatter.php, line 185

Class

DiffFormatter
Diff formatter which uses returns output that can be rendered to a table.

Namespace

Drupal\Core\Diff

Code

protected function _changed($orig, $closing) {
    $orig = array_map('\\Drupal\\Component\\Utility\\Html::escape', $orig);
    $closing = array_map('\\Drupal\\Component\\Utility\\Html::escape', $closing);
    $diff = new WordLevelDiff($orig, $closing);
    $del = $diff->orig();
    $add = $diff->closing();
    // Notice that WordLevelDiff returns HTML-escaped output. Hence, we will be
    // calling addedLine/deletedLine without HTML-escaping.
    while ($line = array_shift($del)) {
        $aline = array_shift($add);
        $this->rows[] = array_merge($this->deletedLine($line), isset($aline) ? $this->addedLine($aline) : $this->emptyLine());
    }
    // If any leftovers.
    foreach ($add as $line) {
        $this->rows[] = array_merge($this->emptyLine(), $this->addedLine($line));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.