Skip to content

Commit 05a1552

Browse files
authored
allow objects to get children class ids (#1748)
1 parent d966524 commit 05a1552

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/Class/Controller/Folder/CollectionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __construct(
7878
public function getFolderClassList(
7979
int $folderId
8080
): JsonResponse {
81-
$collection = $this->classDefinitionTreeService->getClassDefinitionIdsInsideFolder($folderId);
81+
$collection = $this->classDefinitionTreeService->getChildrenClassDefinitionIds($folderId);
8282

8383
return $this->getPaginatedCollection(
8484
$this->serializer,

src/Class/Service/ClassDefinitionTreeService.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
use Pimcore\Bundle\StudioBackendBundle\Element\Service\ElementServiceInterface;
2525
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
2626
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\ElementTypes;
27+
use Pimcore\Model\DataObject;
2728
use Pimcore\Model\DataObject\ClassDefinition;
28-
use Pimcore\Model\DataObject\Folder;
2929
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
3030
use function count;
3131

@@ -69,15 +69,15 @@ public function getTree(bool $grouped = false): array
6969
return $hydrated;
7070
}
7171

72-
public function getClassDefinitionIdsInsideFolder(int $folderId): array
72+
public function getChildrenClassDefinitionIds(int $parentId): array
7373
{
74-
$folder = $this->elementService->getElementById(ElementTypes::TYPE_DATA_OBJECT, $folderId);
75-
if (!$folder instanceof Folder) {
76-
throw new NotFoundException(ElementTypes::TYPE_DATA_OBJECT . ' Folder', $folderId);
74+
$object = $this->elementService->getElementById(ElementTypes::TYPE_DATA_OBJECT, $parentId);
75+
if (!$object instanceof DataObject) {
76+
throw new NotFoundException(ElementTypes::TYPE_DATA_OBJECT . ' Parent', $parentId);
7777
}
7878

7979
$hydratedClassDefinitions = [];
80-
foreach ($folder->getDao()->getClasses() as $classDefinition) {
80+
foreach ($object->getDao()->getClasses() as $classDefinition) {
8181
$class = $this->classDefinitionFolderListHydrator->hydrate($classDefinition);
8282
$this->eventDispatcher->dispatch(
8383
new ClassDefinitionFolderListEvent($class),

src/Class/Service/ClassDefinitionTreeServiceInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ public function getTree(bool $grouped = true): array;
3030
/**
3131
* @throws NotFoundException
3232
*/
33-
public function getClassDefinitionIdsInsideFolder(int $folderId): array;
33+
public function getChildrenClassDefinitionIds(int $parentId): array;
3434
}

0 commit comments

Comments
 (0)