{% macro dump(value, separator) %}
{% import _self as helper %}
{% apply spaceless %}
{% if value.label is defined %}
{{ value.label }}
{% elseif value is iterable %}
{% for k, v in value %}
{{ k }}: {{ helper.dump(v) }}{{ separator|default('
')|raw }}
{% endfor %}
{% else %}
{{ value }}
{% endif %}
{% endapply %}
{% endmacro dump %}
{% macro namespaceToParam(entity) %}
{{- entity|replace({'\\': '-'}) -}}
{% endmacro namespaceToParam %}
{% macro humanize(entity, entry) %}
{% import _self as helper %}
{% set diffs = entry.diffs|json_decode(true) %}
{% set subject = entity~'#'~entry.object_id %}
{% if entry.type == 'insert' %}
{% set action = 'inserted' %}
{% elseif entry.type == 'update' %}
{% set action = 'updated' %}
{% elseif entry.type == 'remove' %}
{% set action = 'deleted' %}
{% set source = diffs %}
{% elseif entry.type == 'associate' %}
{% set action = 'associated' %}
{% set source = diffs.source %}
{% set target = diffs.target %}
{% set direction = 'to' %}
{% elseif entry.type == 'dissociate' %}
{% set action = 'dissociated' %}
{% set source = diffs.source %}
{% set target = diffs.target %}
{% set direction = 'from' %}
{% else %}
{% set action = '???' %}
{% endif %}
{{ subject }}
{% if source is defined and subject != source.label %}
({{ source.label }})
{% endif %}
has been {{ action }}
{% if target is defined %}
{% set subject = target.class~'#'~target.id %}
{{ direction }} {{ subject }}
{% if subject != target.label %}
({{ helper.dump(target) }})
{% endif %}
{% endif %}
by {{ entry.blame_user is null ? 'unknown user' : entry.blame_user }}
{% if entry.ip is not empty %}
, IP: {{ entry.ip }}
{% endif %}
{% endmacro %}