[CONTROLLER][Actor] Handle case where there isn't a logged in user

This commit is contained in:
Hugo Sales 2021-12-21 16:55:48 +00:00 committed by Diogo Peralta Cordeiro
parent 4b98200ecd
commit 67f09d4e50
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 9 additions and 7 deletions

View File

@ -130,7 +130,7 @@ class Actor extends ActorController
} }
} }
$notes = DB::dql( $notes = !\is_null($group) ? DB::dql(
<<<'EOF' <<<'EOF'
select n from note n select n from note n
join activity a with n.id = a.object_id join activity a with n.id = a.object_id
@ -138,12 +138,12 @@ class Actor extends ActorController
where a.object_type = 'note' and gi.group_id = :group_id where a.object_type = 'note' and gi.group_id = :group_id
EOF, EOF,
['group_id' => $group->getId()], ['group_id' => $group->getId()],
); ) : [];
return [ return [
'_template' => 'actor/group_view.html.twig', '_template' => 'actor/group_view.html.twig',
'actor' => $group, 'actor' => $group,
'nickname' => $group->getNickname(), 'nickname' => $group?->getNickname() ?? $nickname,
'notes' => $notes, 'notes' => $notes,
]; ];
} }

View File

@ -1,8 +1,7 @@
{% extends 'stdgrid.html.twig' %} {% extends 'stdgrid.html.twig' %}
{% import '/cards/note/view.html.twig' as noteView %} {% import '/cards/note/view.html.twig' as noteView %}
{% set nickname = nickname|escape %}
{% block title %}{{ nickname }}{% endblock %} {% block title %}{{ nickname }}{% endblock %}
{% block stylesheets %} {% block stylesheets %}
@ -38,8 +37,11 @@
{% else %} {% else %}
<div class="section-widget-padded section-widget"> <div class="section-widget-padded section-widget">
<p>{% trans with { '%group%': nickname } %}The group <em>%group%</em> doesn't exist. Would you like to create it?{% endtrans %}</p> <p>{% trans with { '%group%': nickname } %}The group <em>%group%</em> doesn't exist.{% endtrans %}</p>
{{ form(create_form) }} {% if create_form is defined and create_form is not null %}
<p>{% trans %}Would you like to create it?{% endtrans %}</p>
{{ form(create_form) }}
{% endif %}
</div> </div>
{% endif %} {% endif %}
{% endblock body %} {% endblock body %}