Skip to content

Commit

Permalink
Refactor remaining hydrators
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed Mar 11, 2024
1 parent 71e1335 commit 2b3924b
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 50 deletions.
46 changes: 24 additions & 22 deletions src/Service/GenericData/V1/Hydrator/Asset/DocumentHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,29 @@ public function __construct(

public function hydrate(DocumentItem $item): Document
{
return new Document(
$item->getPageCount(),
$item->getImageThumbnail(),
$this->iconService->getIconForAsset($item->getType(), $item->getMimeType()),
$item->isHasChildren(),
$item->getType(),
$item->getKey(),
$item->getMimeType(),
$this->metaDataHydrator->hydrate($item->getMetaData()),
$item->isHasWorkflowWithPermissions(),
$item->getFullPath(),
$item->getId(),
$item->getParentId(),
$item->getPath(),
$item->getUserOwner(),
$item->getUserModification(),
$item->getLocked(),
$item->isLocked(),
$item->getCreationDate(),
$item->getModificationDate(),
$this->permissionsHydrator->hydrate($item->getPermissions())
);
$document = new Document($item->getId());

$document->setParentId($item->getParentId());
$document->setPath($item->getPath());
$document->setUserOwner($item->getUserOwner());
$document->setUserModification($item->getUserModification());
$document->setLocked($item->getLocked());
$document->setIsLocked($item->isLocked());
$document->setCreationDate($item->getCreationDate());
$document->setModificationDate($item->getModificationDate());
$document->setPermissions($this->permissionsHydrator->hydrate($item->getPermissions()));
$document->setUserModification($item->getUserModification());

// asset specific stuff
$document->setIconName($this->iconService->getIconForAsset($item->getType(), $item->getMimeType()));
$document->setHasChildren($item->isHasChildren());
$document->setType($item->getType());
$document->setFilename($item->getKey());
$document->setMimeType($item->getMimeType());
$document->setMetaData($this->metaDataHydrator->hydrate($item->getMetaData()));
$document->setWorkflowWithPermissions($item->isHasWorkflowWithPermissions());
$document->setFullPath($item->getFullPath());

$document->setPageCount($item->getPageCount());

Check failure on line 58 in src/Service/GenericData/V1/Hydrator/Asset/DocumentHydrator.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.2, highest, false)

Method Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Hydrator\Asset\DocumentHydrator::hydrate() should return Pimcore\Bundle\StudioApiBundle\Dto\Asset\Document but return statement is missing.

Check failure on line 58 in src/Service/GenericData/V1/Hydrator/Asset/DocumentHydrator.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.2, highest, 11.x-dev as 11.99.9, true)

Method Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Hydrator\Asset\DocumentHydrator::hydrate() should return Pimcore\Bundle\StudioApiBundle\Dto\Asset\Document but return statement is missing.
}
}
28 changes: 24 additions & 4 deletions src/Service/GenericData/V1/Hydrator/Asset/FolderHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,29 @@ public function __construct(

public function hydrate(FolderItem $item): Folder
{
return new Folder(
$item->getId()
);
// TODO Implement hydrate() method.
$folder = new Folder($item->getId());

$folder->setParentId($item->getParentId());
$folder->setPath($item->getPath());
$folder->setUserOwner($item->getUserOwner());
$folder->setUserModification($item->getUserModification());
$folder->setLocked($item->getLocked());
$folder->setIsLocked($item->isLocked());
$folder->setCreationDate($item->getCreationDate());
$folder->setModificationDate($item->getModificationDate());
$folder->setPermissions($this->permissionsHydrator->hydrate($item->getPermissions()));
$folder->setUserModification($item->getUserModification());

// asset specific stuff
$folder->setIconName($this->iconService->getIconForAsset($item->getType(), $item->getMimeType()));
$folder->setHasChildren($item->isHasChildren());
$folder->setType($item->getType());
$folder->setFilename($item->getKey());
$folder->setMimeType($item->getMimeType());
$folder->setMetaData($this->metaDataHydrator->hydrate($item->getMetaData()));
$folder->setWorkflowWithPermissions($item->isHasWorkflowWithPermissions());
$folder->setFullPath($item->getFullPath());

return $folder;
}
}
50 changes: 26 additions & 24 deletions src/Service/GenericData/V1/Hydrator/Asset/VideoHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,31 @@ public function __construct(

public function hydrate(VideoItem $item): Video
{
return new Video(
$item->getDuration(),
$item->getWidth(),
$item->getHeight(),
$item->getImageThumbnail(),
$this->iconService->getIconForAsset($item->getType(), $item->getMimeType()),
$item->isHasChildren(),
$item->getType(),
$item->getKey(),
$item->getMimeType(),
$this->metaDataHydrator->hydrate($item->getMetaData()),
$item->isHasWorkflowWithPermissions(),
$item->getFullPath(),
$item->getId(),
$item->getParentId(),
$item->getPath(),
$item->getUserOwner(),
$item->getUserModification(),
$item->getLocked(),
$item->isLocked(),
$item->getCreationDate(),
$item->getModificationDate(),
$this->permissionsHydrator->hydrate($item->getPermissions())
);
$video = new Video($item->getId());

$video->setParentId($item->getParentId());
$video->setPath($item->getPath());
$video->setUserOwner($item->getUserOwner());
$video->setUserModification($item->getUserModification());
$video->setLocked($item->getLocked());
$video->setIsLocked($item->isLocked());
$video->setCreationDate($item->getCreationDate());
$video->setModificationDate($item->getModificationDate());
$video->setPermissions($this->permissionsHydrator->hydrate($item->getPermissions()));
$video->setUserModification($item->getUserModification());

// asset specific stuff
$video->setIconName($this->iconService->getIconForAsset($item->getType(), $item->getMimeType()));
$video->setHasChildren($item->isHasChildren());
$video->setType($item->getType());
$video->setFilename($item->getKey());
$video->setMimeType($item->getMimeType());
$video->setMetaData($this->metaDataHydrator->hydrate($item->getMetaData()));
$video->setWorkflowWithPermissions($item->isHasWorkflowWithPermissions());
$video->setFullPath($item->getFullPath());

$video->setDuration($item->getDuration());

return $video;
}
}

0 comments on commit 2b3924b

Please sign in to comment.