function DiffFormatter::_block

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Component/Diff/DiffFormatter.php \Drupal\Component\Diff\DiffFormatter::_block()
  2. 10 core/lib/Drupal/Component/Diff/DiffFormatter.php \Drupal\Component\Diff\DiffFormatter::_block()
  3. 9 core/lib/Drupal/Component/Diff/DiffFormatter.php \Drupal\Component\Diff\DiffFormatter::_block()
  4. 8.9.x core/lib/Drupal/Component/Diff/DiffFormatter.php \Drupal\Component\Diff\DiffFormatter::_block()

Format a diff block.

Parameters

int $xbeg: Starting line number in the original block.

int $xlen: Length of the changed lines in the original block.

int $ybeg: Starting line number in the new block.

int $ylen: Length of the changed lines in the new block.

\Drupal\Component\Diff\Engine\DiffOp[] $edits: An array of diff operations.

Return value

void No return value.

1 call to DiffFormatter::_block()
DiffFormatter::format in core/lib/Drupal/Component/Diff/DiffFormatter.php
Format a diff.

File

core/lib/Drupal/Component/Diff/DiffFormatter.php, line 149

Class

DiffFormatter
A class to format Diffs.

Namespace

Drupal\Component\Diff

Code

protected function _block($xbeg, $xlen, $ybeg, $ylen, &$edits) {
  $this->_start_block($this->_block_header($xbeg, $xlen, $ybeg, $ylen));
  foreach ($edits as $edit) {
    if ($edit->type == 'copy') {
      $this->_context($edit->orig);
    }
    elseif ($edit->type == 'add') {
      $this->_added($edit->closing);
    }
    elseif ($edit->type == 'delete') {
      $this->_deleted($edit->orig);
    }
    elseif ($edit->type == 'change') {
      $this->_changed($edit->orig, $edit->closing);
    }
    else {
      trigger_error('Unknown edit type', E_USER_WARNING);
    }
  }
  $this->_end_block();
}

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