diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index c10118c..44cf3b7 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -30,6 +30,9 @@ 'phpdoc_to_param_type' => true, 'phpdoc_to_property_type' => true, 'phpdoc_to_return_type' => true, + 'phpdoc_to_comment' => [ + 'ignored_tags' => ['todo', 'var'] + ], 'regular_callable_call' => true, 'simplified_if_return' => true, 'get_class_to_class_keyword' => true, diff --git a/composer.json b/composer.json index c1ec8e6..5dc2367 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": ">=8.2", "ext-intl": "*", - "damienharper/auditor": "^2.3|^3.0", + "damienharper/auditor": "^3.2", "doctrine/doctrine-bundle": "^2.0", "symfony/asset": "^5.4|^6.4|^7.0", "symfony/doctrine-bridge": "^5.4|^6.4|^7.0", diff --git a/phpunit.xml b/phpunit.xml index 6609306..77f2eb4 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,30 +1,30 @@ - - - - - - - - - - - - - - - - - tests - - - - - src - - + + + + + + + + + + + + + + + + + tests + + + + + src + + diff --git a/src/Resources/views/Audit/entry.html.twig b/src/Resources/views/Audit/entry.html.twig index fac39ca..43d234c 100644 --- a/src/Resources/views/Audit/entry.html.twig +++ b/src/Resources/views/Audit/entry.html.twig @@ -1,5 +1,18 @@ {% import '@DHAuditor/Audit/helpers/helper.html.twig' as helper %} +{% macro displayDiffs(field, changeset) %} +{# {{ dump(field, changeset) }}#} + {% if changeset.old is defined or changeset.new is defined %} + {# NON JSON field changeset #} + {{ include('@DHAuditor/Audit/entry_diff.html.twig', {'key': field, 'values': changeset}) }} + {% else %} + {# JSON field changeset #} + {% for json_field, json_changeset in changeset %} + {{ _self.displayDiffs(field~'.'~json_field, json_changeset) }} + {% endfor %} + {% endif %} +{% endmacro %} +
{% if not is_last %} @@ -46,34 +59,8 @@ {% set diffs = entry.getDiffs() %} - {% for key, values in diffs %} - - - {{ key }} - - - {% if values.old is defined %} - {% if values.old is null %} - null - {% else %} - {{ helper.dump(values.old) }} - {% endif %} - {% endif %} - - - {% if values.new is defined %} - {% if values.new is null %} - null - {% else %} - {% if values.old is null %} - {{ helper.dump(values.new) }} - {% else %} - {{ helper.dump(values.new) }} - {% endif %} - {% endif %} - {% endif %} - - + {% for field, changeset in diffs %} + {{ _self.displayDiffs(field, changeset) }} {% endfor %} @@ -97,4 +84,3 @@
- diff --git a/src/Resources/views/Audit/entry_diff.html.twig b/src/Resources/views/Audit/entry_diff.html.twig new file mode 100644 index 0000000..d9f85a7 --- /dev/null +++ b/src/Resources/views/Audit/entry_diff.html.twig @@ -0,0 +1,30 @@ +{% import '@DHAuditor/Audit/helpers/helper.html.twig' as helper %} + + + +{#{{ dump('entry_diff', key, values) }}#} + {{ key }} + + + {% if values.old is defined %} + {% if values.old is null %} + null + {% else %} + {{ helper.dump(values.old) }} + {% endif %} + {% endif %} + + + {% if values.new is defined %} + {% if values.new is null %} + null + {% else %} + {% if values.old is not defined or values.old is null %} + {{ helper.dump(values.new) }} + {% else %} + {{ helper.dump(values.new) }} + {% endif %} + {% endif %} + {% endif %} + +