Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Class/Controller/Folder/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct(
public function getFolderClassList(
int $folderId
): JsonResponse {
$collection = $this->classDefinitionTreeService->getClassDefinitionIdsInsideFolder($folderId);
$collection = $this->classDefinitionTreeService->getChildrenClassDefinitionIds($folderId);

return $this->getPaginatedCollection(
$this->serializer,
Expand Down
12 changes: 6 additions & 6 deletions src/Class/Service/ClassDefinitionTreeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
use Pimcore\Bundle\StudioBackendBundle\Element\Service\ElementServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\ElementTypes;
use Pimcore\Model\DataObject;
use Pimcore\Model\DataObject\ClassDefinition;
use Pimcore\Model\DataObject\Folder;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use function count;

Expand Down Expand Up @@ -69,15 +69,15 @@ public function getTree(bool $grouped = false): array
return $hydrated;
}

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

$hydratedClassDefinitions = [];
foreach ($folder->getDao()->getClasses() as $classDefinition) {
foreach ($object->getDao()->getClasses() as $classDefinition) {
$class = $this->classDefinitionFolderListHydrator->hydrate($classDefinition);
$this->eventDispatcher->dispatch(
new ClassDefinitionFolderListEvent($class),
Expand Down
2 changes: 1 addition & 1 deletion src/Class/Service/ClassDefinitionTreeServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ public function getTree(bool $grouped = true): array;
/**
* @throws NotFoundException
*/
public function getClassDefinitionIdsInsideFolder(int $folderId): array;
public function getChildrenClassDefinitionIds(int $parentId): array;
}
Loading