12
12
use eZ \Publish \API \Repository \ContentTypeService ;
13
13
use eZ \Publish \API \Repository \LocationService ;
14
14
use eZ \Publish \API \Repository \PermissionResolver ;
15
+ use eZ \Publish \API \Repository \SearchService ;
15
16
use eZ \Publish \API \Repository \Values \Content \Content ;
16
17
use eZ \Publish \API \Repository \Values \Content \Location ;
17
18
use eZ \Publish \API \Repository \Values \ContentType \ContentType ;
18
19
use eZ \Publish \Core \MVC \Symfony \View \ContentView ;
20
+ use eZ \Publish \Core \Query \QueryFactoryInterface ;
19
21
use EzSystems \EzPlatformAdminUi \UI \Config \Provider \ContentTypeMappings ;
20
22
use EzSystems \EzPlatformAdminUi \UI \Module \Subitems \ValueObjectVisitor \SubitemsList as SubitemsListValueObjectVisitor ;
21
23
use EzSystems \EzPlatformAdminUi \UI \Module \Subitems \Values \SubitemsList ;
@@ -63,18 +65,12 @@ class ContentViewParameterSupplier
63
65
/** @var \EzSystems\EzPlatformUser\UserSetting\UserSettingService */
64
66
private $ userSettingService ;
65
67
66
- /**
67
- * @param \EzSystems\EzPlatformRest\Output\Visitor $outputVisitor
68
- * @param \EzSystems\EzPlatformRest\Output\Generator\Json $outputGenerator
69
- * @param \EzSystems\EzPlatformRest\Server\Output\ValueObjectVisitor\ContentTypeInfoList $contentTypeInfoListValueObjectVisitor
70
- * @param \EzSystems\EzPlatformAdminUi\UI\Module\Subitems\ValueObjectVisitor\SubitemsList $subitemsListValueObjectVisitor
71
- * @param \eZ\Publish\API\Repository\LocationService $locationService
72
- * @param \eZ\Publish\API\Repository\ContentService $contentService
73
- * @param \eZ\Publish\API\Repository\ContentTypeService $contentTypeService
74
- * @param \eZ\Publish\API\Repository\PermissionResolver $permissionResolver
75
- * @param \EzSystems\EzPlatformAdminUi\UI\Config\Provider\ContentTypeMappings $contentTypeMappings
76
- * @param \EzSystems\EzPlatformUser\UserSetting\UserSettingService $userSettingService
77
- */
68
+ /** @var \eZ\Publish\Core\Query\QueryFactoryInterface */
69
+ private $ queryFactory ;
70
+
71
+ /** @var \eZ\Publish\API\Repository\SearchService */
72
+ private $ searchService ;
73
+
78
74
public function __construct (
79
75
Visitor $ outputVisitor ,
80
76
JsonOutputGenerator $ outputGenerator ,
@@ -85,7 +81,9 @@ public function __construct(
85
81
ContentTypeService $ contentTypeService ,
86
82
PermissionResolver $ permissionResolver ,
87
83
ContentTypeMappings $ contentTypeMappings ,
88
- UserSettingService $ userSettingService
84
+ UserSettingService $ userSettingService ,
85
+ QueryFactoryInterface $ queryFactory ,
86
+ SearchService $ searchService
89
87
) {
90
88
$ this ->outputVisitor = $ outputVisitor ;
91
89
$ this ->outputGenerator = $ outputGenerator ;
@@ -97,6 +95,8 @@ public function __construct(
97
95
$ this ->permissionResolver = $ permissionResolver ;
98
96
$ this ->contentTypeMappings = $ contentTypeMappings ;
99
97
$ this ->userSettingService = $ userSettingService ;
98
+ $ this ->queryFactory = $ queryFactory ;
99
+ $ this ->searchService = $ searchService ;
100
100
}
101
101
102
102
/**
@@ -121,12 +121,17 @@ public function supply(ContentView $view)
121
121
$ contentTypes = [];
122
122
$ subitemsRows = [];
123
123
$ location = $ view ->getLocation ();
124
- $ childrenCount = $ this ->locationService ->getLocationChildCount ($ location );
125
-
126
124
$ subitemsLimit = (int )$ this ->userSettingService ->getUserSetting ('subitems_limit ' )->value ;
127
125
128
- $ locationChildren = $ this ->locationService ->loadLocationChildren ($ location , 0 , $ subitemsLimit );
129
- foreach ($ locationChildren ->locations as $ locationChild ) {
126
+ /** @var \eZ\Publish\API\Repository\Values\Content\LocationQuery $locationChildrenQuery */
127
+ $ locationChildrenQuery = $ this ->queryFactory ->create ('Children ' , ['location ' => $ location ]);
128
+ $ locationChildrenQuery ->offset = 0 ;
129
+ $ locationChildrenQuery ->limit = $ subitemsLimit ;
130
+
131
+ $ searchResult = $ this ->searchService ->findLocations ($ locationChildrenQuery );
132
+ foreach ($ searchResult ->searchHits as $ searchHit ) {
133
+ /** @var \eZ\Publish\API\Repository\Values\Content\Location $locationChild */
134
+ $ locationChild = $ searchHit ->valueObject ;
130
135
$ contentType = $ locationChild ->getContent ()->getContentType ();
131
136
132
137
if (!isset ($ contentTypes [$ contentType ->identifier ])) {
@@ -136,7 +141,7 @@ public function supply(ContentView $view)
136
141
$ subitemsRows [] = $ this ->createSubitemsRow ($ locationChild , $ contentType );
137
142
}
138
143
139
- $ subitemsList = new SubitemsList ($ subitemsRows , $ childrenCount );
144
+ $ subitemsList = new SubitemsList ($ subitemsRows , $ searchResult -> totalCount );
140
145
$ contentTypeInfoList = new ContentTypeInfoList ($ contentTypes , '' );
141
146
142
147
$ subitemsListJson = $ this ->visitSubitemsList ($ subitemsList );
0 commit comments