Skip to content

Commit 53fbc92

Browse files
committed
Merge pull request #6 from caxy/feature-insert_space_in_replace
Configuration option for inserting space in replace
2 parents 215a741 + 703bb94 commit 53fbc92

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

DependencyInjection/Configuration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public function getConfigTreeBuilder()
3030
->prototype('scalar')->end()
3131
->end()
3232
->booleanNode('group_diffs')->end()
33+
->booleanNode('insert_space_in_replace')
34+
->defaultFalse()
35+
->end()
3336
->end();
3437

3538
return $treeBuilder;

Service/HtmlDiffService.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class HtmlDiffService
1111
const PARAMETER_SPECIAL_CASE_CHARS = 'special_case_chars';
1212
const PARAMETER_ENCODING = 'encoding';
1313
const PARAMETER_GROUP_DIFFS = 'group_diffs';
14+
const PARAMETER_INSERT_SPACE_IN_REPLACE = 'insert_space_in_replace';
1415

1516
protected $container;
1617

@@ -20,6 +21,8 @@ class HtmlDiffService
2021

2122
protected $groupDiffs;
2223

24+
protected $insertSpaceInReplace;
25+
2326
protected $encoding = 'UTF-8';
2427

2528
public function __construct(ContainerInterface $container)
@@ -34,6 +37,7 @@ public function __construct(ContainerInterface $container)
3437
$this->loadParameter(self::PARAMETER_SPECIAL_CASE_TAGS, $this->specialCaseTags);
3538
$this->loadParameter(self::PARAMETER_SPECIAL_CASE_CHARS, $this->specialCaseChars);
3639
$this->loadParameter(self::PARAMETER_GROUP_DIFFS, $this->groupDiffs);
40+
$this->loadParameter(self::PARAMETER_INSERT_SPACE_IN_REPLACE, $this->insertSpaceInReplace);
3741
}
3842

3943
public function loadParameter($param, &$property)
@@ -60,6 +64,10 @@ public function diff($oldText, $newText, $groupDiffs = null, $specialCaseChars =
6064
$diff->setSpecialCaseChars($specialCaseChars);
6165
}
6266

67+
if ($this->insertSpaceInReplace !== null) {
68+
$diff->setInsertSpaceInReplace($this->insertSpaceInReplace);
69+
}
70+
6371
return $diff->build();
6472
}
6573

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"require": {
1616
"php": ">=5.3.3",
1717
"symfony/framework-bundle": "~2.1",
18-
"caxy/php-htmldiff": ">=0.0.1"
18+
"caxy/php-htmldiff": ">=0.0.3"
1919
},
2020
"target-dir": "Caxy/HtmlDiffBundle",
2121
"autoload": {

0 commit comments

Comments
 (0)