@@ -28,44 +28,61 @@ public function __invoke(int $contentId, Request $request): Response
2828
2929 if ($ content ->getContentInfo ()->isHidden () === true ) {
3030 $ title = $ this ->translator ->trans ('content.visibility.content_hidden ' , [], 'locationview ' );
31- } else {
32- try {
33- $ locations = $ this ->locationService ->loadLocations ($ content ->getContentInfo ());
31+ }
32+
33+ try {
34+ $ locations = $ this ->locationService ->loadLocations ($ content ->getContentInfo ());
3435
35- $ hiddenLocations = 0 ;
36- foreach ($ locations as $ location ) {
37- if ($ location ->explicitlyHidden || $ location ->invisible ) {
38- $ hiddenLocations ++;
39- }
36+ $ hiddenLocations = 0 ;
37+ $ hiddenByAncestor = false ;
38+ foreach ($ locations as $ location ) {
39+ if ($ location ->explicitlyHidden ) {
40+ $ hiddenLocations ++;
41+ continue ;
4042 }
4143
42- if ($ hiddenLocations !== 0 ) {
43- if (count ($ locations ) === 1 ) {
44- $ title = $ this ->translator ->trans ('content.visibility.location_hidden ' , [], 'locationview ' );
45- } else {
46- $ title = $ this ->translator ->trans (
44+ if ($ location ->isInvisible () && $ location ->getParentLocation ()?->isInvisible()) {
45+ $ hiddenLocations ++;
46+ $ hiddenByAncestor = true ;
47+ }
48+ }
49+
50+ if ($ hiddenLocations !== 0 ) {
51+ if (count ($ locations ) === 1 ) {
52+ $ extraContent = $ this ->translator ->trans ('content.visibility.location_hidden ' , [], 'locationview ' );
53+ } else {
54+ $ extraContent = $ hiddenByAncestor
55+ ? $ this ->translator ->trans (
56+ 'content.visibility.locations_hidden_by_ancestor ' ,
57+ [
58+ '%hidden% ' => $ hiddenLocations ,
59+ '%total% ' => count ($ locations ),
60+ ],
61+ 'locationview ' ,
62+ )
63+ : $ this ->translator ->trans (
4764 'content.visibility.locations_hidden ' ,
4865 [
4966 '%hidden% ' => $ hiddenLocations ,
5067 '%total% ' => count ($ locations ),
5168 ],
5269 'locationview ' ,
5370 );
54- }
5571 }
56- } catch (BadStateException $ e ) {
57- $ title = $ this ->translator ->trans ('content.visibility.cannot_fetch_locations ' , [], 'locationview ' );
5872 }
73+ } catch (BadStateException $ e ) {
74+ $ extraContent = $ this ->translator ->trans ('content.visibility.cannot_fetch_locations ' , [], 'locationview ' );
5975 }
6076
61- if (!isset ($ title )) {
77+ if (!isset ($ title ) && ! isset ( $ extraContent ) ) {
6278 return new Response ('' , Response::HTTP_NO_CONTENT );
6379 }
6480
6581 return $ this ->render ('@IbexaAdminUi/themes/admin/ui/component/alert/alert.html.twig ' ,
6682 [
6783 'type ' => 'info ' ,
68- 'title ' => $ title ,
84+ 'title ' => $ title ?? '' ,
85+ 'extra_content ' => $ extraContent ?? '' ,
6986 'icon_path ' => $ iconPath ,
7087 'class ' => 'mt-4 ' ,
7188 ],
0 commit comments