2015-09-14 13:37:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director;
|
|
|
|
|
2020-11-25 14:51:00 +01:00
|
|
|
use gipfl\Diff\HtmlRenderer\InlineDiff;
|
|
|
|
use gipfl\Diff\HtmlRenderer\SideBySideDiff;
|
|
|
|
use gipfl\Diff\PhpDiff;
|
2019-05-02 13:23:06 +02:00
|
|
|
use ipl\Html\ValidHtml;
|
2018-10-04 06:46:32 +02:00
|
|
|
use InvalidArgumentException;
|
2015-09-14 13:37:27 +02:00
|
|
|
|
2020-11-25 14:51:00 +01:00
|
|
|
/**
|
|
|
|
* @deprecated will be removed with v1.9 - please use gipfl\Diff
|
|
|
|
*/
|
2017-07-25 14:04:08 +02:00
|
|
|
class ConfigDiff implements ValidHtml
|
2015-09-14 13:37:27 +02:00
|
|
|
{
|
2020-11-25 14:51:00 +01:00
|
|
|
protected $renderClass;
|
2015-09-14 13:37:27 +02:00
|
|
|
|
2020-11-25 14:51:00 +01:00
|
|
|
/** @var PhpDiff */
|
|
|
|
protected $phpDiff;
|
2015-09-14 13:37:27 +02:00
|
|
|
|
2020-11-25 14:51:00 +01:00
|
|
|
public function __construct($a, $b)
|
2015-09-14 13:37:27 +02:00
|
|
|
{
|
2020-11-25 14:51:00 +01:00
|
|
|
$this->phpDiff = new PhpDiff($a, $b);
|
2015-09-14 13:37:27 +02:00
|
|
|
}
|
|
|
|
|
2017-07-25 14:04:08 +02:00
|
|
|
public function render()
|
|
|
|
{
|
2020-11-25 14:51:00 +01:00
|
|
|
$class = $this->renderClass;
|
|
|
|
return (new $class($this->phpDiff))->render();
|
2015-11-05 12:30:07 +01:00
|
|
|
}
|
|
|
|
|
2018-10-04 06:46:32 +02:00
|
|
|
public function setHtmlRenderer($name)
|
2015-11-05 12:30:07 +01:00
|
|
|
{
|
2020-11-25 14:51:00 +01:00
|
|
|
switch ($name) {
|
|
|
|
case 'SideBySide':
|
|
|
|
$this->renderClass = SideBySideDiff::class;
|
|
|
|
break;
|
|
|
|
case 'Inline':
|
|
|
|
$this->renderClass = InlineDiff::class;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw new InvalidArgumentException("There is no known '$name' renderer");
|
2018-10-04 06:46:32 +02:00
|
|
|
}
|
2015-11-05 12:30:07 +01:00
|
|
|
|
2018-10-04 06:46:32 +02:00
|
|
|
return $this;
|
2015-11-05 12:30:07 +01:00
|
|
|
}
|
2015-09-14 13:37:27 +02:00
|
|
|
}
|