|
10 | 10 | use Doctrine\DBAL\FetchMode; |
11 | 11 | use Doctrine\DBAL\ParameterType; |
12 | 12 | use Doctrine\DBAL\Query\QueryBuilder; |
| 13 | +use Doctrine\DBAL\Result; |
13 | 14 | use Ibexa\Contracts\Core\Persistence\Content\ContentInfo; |
14 | 15 | use Ibexa\Contracts\Core\Persistence\Content\Location; |
15 | 16 | use Ibexa\Contracts\Core\Persistence\Content\Location\CreateStruct; |
@@ -237,6 +238,29 @@ public function getSubtreeContent(int $sourceId, bool $onlyIds = false): array |
237 | 238 | : $results; |
238 | 239 | } |
239 | 240 |
|
| 241 | + /** |
| 242 | + * @return array<int> |
| 243 | + * |
| 244 | + * @throws \Doctrine\DBAL\Exception |
| 245 | + * @throws \Doctrine\DBAL\Driver\Exception |
| 246 | + */ |
| 247 | + public function getSubtreeChildrenDraftContentIds(int $sourceId): array |
| 248 | + { |
| 249 | + $query = $this->connection->createQueryBuilder(); |
| 250 | + $query |
| 251 | + ->select('contentobject_id') |
| 252 | + ->from('eznode_assignment', 'n') |
| 253 | + ->innerJoin('n', 'ezcontentobject', 'c', 'n.contentobject_id = c.id') |
| 254 | + ->andWhere('n.parent_node = :parentNode') |
| 255 | + ->andWhere('c.status = :status') |
| 256 | + ->setParameter(':parentNode', $sourceId, ParameterType::INTEGER) |
| 257 | + ->setParameter(':status', ContentInfo::STATUS_DRAFT, ParameterType::INTEGER); |
| 258 | + |
| 259 | + $statement = $query->execute(); |
| 260 | + |
| 261 | + return $statement instanceof Result ? $statement->fetchFirstColumn() : []; |
| 262 | + } |
| 263 | + |
240 | 264 | public function getSubtreeSize(string $path): int |
241 | 265 | { |
242 | 266 | $query = $this->createNodeQueryBuilder([$this->dbPlatform->getCountExpression('node_id')]); |
|
0 commit comments