|
@@ 218-238 (lines=21) @@
|
| 215 |
|
* @param string[] $contentTypeIdentifiers |
| 216 |
|
* @return Content[] |
| 217 |
|
*/ |
| 218 |
|
protected function findContentsByContentTypeIdentifiers(array $contentTypeIdentifiers) |
| 219 |
|
{ |
| 220 |
|
$query = new Query(); |
| 221 |
|
$query->limit = PHP_INT_MAX; |
| 222 |
|
$query->filter = new Query\Criterion\ContentTypeIdentifier($contentTypeIdentifiers); |
| 223 |
|
// sort objects by depth, lower to higher, so that deleting them has less chances of failure |
| 224 |
|
// NB: we only do this in eZP versions that allow depth sorting on content queries |
| 225 |
|
if (class_exists('eZ\Publish\API\Repository\Values\Content\Query\SortClause\LocationDepth')) { |
| 226 |
|
$query->sortClauses = array(new Query\SortClause\LocationDepth(Query::SORT_DESC)); |
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
$results = $this->repository->getSearchService()->findContent($query); |
| 230 |
|
|
| 231 |
|
$contents = []; |
| 232 |
|
foreach ($results->searchHits as $result) { |
| 233 |
|
// make sure we return every object only once |
| 234 |
|
$contents[$result->valueObject->contentInfo->id] = $result->valueObject; |
| 235 |
|
} |
| 236 |
|
|
| 237 |
|
return $contents; |
| 238 |
|
} |
| 239 |
|
|
| 240 |
|
/** |
| 241 |
|
* @param int[] $contentTypeIds |
|
@@ 244-263 (lines=20) @@
|
| 241 |
|
* @param int[] $contentTypeIds |
| 242 |
|
* @return Content[] |
| 243 |
|
*/ |
| 244 |
|
protected function findContentsByContentTypeIds(array $contentTypeIds) |
| 245 |
|
{ |
| 246 |
|
$query = new Query(); |
| 247 |
|
$query->limit = PHP_INT_MAX; |
| 248 |
|
$query->filter = new Query\Criterion\ContentTypeId($contentTypeIds); |
| 249 |
|
// sort objects by depth, lower to higher, so that deleting them has less chances of failure |
| 250 |
|
// NB: we only do this in eZP versions that allow depth sorting on content queries |
| 251 |
|
if (class_exists('eZ\Publish\API\Repository\Values\Content\Query\SortClause\LocationDepth')) { |
| 252 |
|
$query->sortClauses = array(new Query\SortClause\LocationDepth(Query::SORT_DESC)); |
| 253 |
|
} |
| 254 |
|
$results = $this->repository->getSearchService()->findContent($query); |
| 255 |
|
|
| 256 |
|
$contents = []; |
| 257 |
|
foreach ($results->searchHits as $result) { |
| 258 |
|
// make sure we return every object only once |
| 259 |
|
$contents[$result->valueObject->contentInfo->id] = $result->valueObject; |
| 260 |
|
} |
| 261 |
|
|
| 262 |
|
return $contents; |
| 263 |
|
} |
| 264 |
|
} |
| 265 |
|
|