-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
258 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
resources: | ||
Pimcore\Bundle\StudioApiBundle\Dto\Asset\Image: | ||
provider: Pimcore\Bundle\StudioApiBundle\State\AssetProvider | ||
provider: Pimcore\Bundle\StudioApiBundle\State\Asset\Provider | ||
processor: Pimcore\Bundle\StudioApiBundle\State\Asset\Processor | ||
operations: | ||
ApiPlatform\Metadata\Get: | ||
normalizationContext: | ||
groups: ['image:read', 'asset:read', 'asset:item:get', 'dependency:read', 'property:read', 'element:read', 'element:item:get' ] | ||
ApiPlatform\Metadata\Put: | ||
properties: | ||
id: | ||
identifier: true | ||
normalizationContext: | ||
groups: ['image:read', 'asset:read', 'dependency:read', 'property:read', 'element:read'] | ||
denormalizationContext: | ||
groups: ['image:write', 'asset:write'] | ||
groups: ['image:write', 'asset:write', 'element:write'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
Pimcore\Bundle\StudioApiBundle\Dto\Asset: | ||
attributes: | ||
type: | ||
groups: ['asset:read'] | ||
groups: ['asset:read', 'asset:write'] | ||
iconName: | ||
groups: [ 'asset:read' ] | ||
groups: [ 'asset:read' , 'asset:write'] | ||
children: | ||
groups: ['asset:read'] | ||
groups: ['asset:read', 'asset:write'] | ||
filename: | ||
groups: ['asset:read'] | ||
groups: ['asset:read', 'asset:write'] | ||
mimetype: | ||
groups: ['asset:read'] | ||
groups: ['asset:read', 'asset:write'] | ||
metadata: | ||
groups: ['asset:read'] | ||
groups: ['asset:read', 'asset:write'] | ||
customSettings: | ||
groups: ['asset:item:get'] | ||
groups: ['asset:item:get', 'asset:write'] | ||
hasMetaData: | ||
groups: ['asset:read'] | ||
groups: ['asset:read', 'asset:write'] | ||
userPermissions: | ||
groups: ['asset:read'] | ||
groups: ['asset:read', 'asset:write'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
Pimcore\Bundle\StudioApiBundle\Dto\Element: | ||
attributes: | ||
id: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] | ||
parentId: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] | ||
permissions: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] | ||
path: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] | ||
creationDate: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] | ||
modificationDate: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] | ||
userOwner: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] | ||
userModification: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] | ||
properties: | ||
groups: ['element:item:get'] | ||
groups: ['element:item:get', 'element:write'] | ||
versions: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] | ||
locked: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] | ||
lock: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] | ||
dependencies: | ||
groups: ['element:item:get'] | ||
groups: ['element:item:get', 'element:write'] | ||
scheduledTasks: | ||
groups: ['element:item:get'] | ||
groups: ['element:item:get', 'element:write'] | ||
versionCount: | ||
groups: ['element:item:get'] | ||
groups: ['element:item:get', 'element:write'] | ||
fullPath: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] | ||
userPermissions: | ||
groups: ['element:read'] | ||
groups: ['element:read', 'element:write'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioApiBundle\Service; | ||
|
||
use Pimcore\Bundle\StaticResolverBundle\Models\Asset\AssetResolverInterface; | ||
use Pimcore\Bundle\StudioApiBundle\Dto\Asset; | ||
use Pimcore\Model\Asset as CoreAsset; | ||
use Pimcore\Model\Exception\NotFoundException; | ||
|
||
final readonly class AssetService implements AssetServiceInterface | ||
{ | ||
public function __construct(private AssetResolverInterface $assetResolver) | ||
{ | ||
} | ||
|
||
public function processAsset(int $id, Asset $data): CoreAsset | ||
{ | ||
$asset = $this->assetResolver->getById($id); | ||
|
||
if(!$asset) { | ||
throw new NotFoundException('Asset not found'); | ||
} | ||
|
||
return $asset; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioApiBundle\Service; | ||
|
||
use Pimcore\Bundle\StudioApiBundle\Dto\Asset; | ||
use Pimcore\Model\Asset as CoreAsset; | ||
|
||
interface AssetServiceInterface | ||
{ | ||
public function processAsset(int $id, Asset $data): CoreAsset; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Pimcore\Bundle\StudioApiBundle\Service\CoreData\V1\Hydrator\Asset; | ||
|
||
use Pimcore\Bundle\StudioApiBundle\Dto\Asset\Image; | ||
use Pimcore\Bundle\StudioApiBundle\Dto\Asset\Permissions; | ||
use Pimcore\Bundle\StudioApiBundle\Service\IconServiceInterface; | ||
use Pimcore\Model\Asset\Image as CoreImage; | ||
|
||
final readonly class ImageHydrator implements ImageHydratorInterface | ||
{ | ||
public function __construct( | ||
private IconServiceInterface $iconService | ||
) { | ||
} | ||
|
||
public function hydrate(CoreImage $item): Image | ||
{ | ||
return new Image( | ||
$item->getWidth(), | ||
$item->getHeight(), | ||
'', | ||
$this->iconService->getIconForAsset($item->getType(), $item->getMimeType()), | ||
false, | ||
$item->getType(), | ||
$item->getFilename(), | ||
$item->getMimeType(), | ||
[], | ||
false, | ||
$item->getFullPath(), | ||
$item->getId(), | ||
$item->getParentId(), | ||
$item->getPath(), | ||
$item->getUserOwner(), | ||
$item->getUserModification(), | ||
$item->getLocked(), | ||
$item->isLocked(), | ||
$item->getCreationDate(), | ||
$item->getModificationDate(), | ||
new Permissions() | ||
); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/Service/CoreData/V1/Hydrator/Asset/ImageHydratorInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Pimcore\Bundle\StudioApiBundle\Service\CoreData\V1\Hydrator\Asset; | ||
|
||
use Pimcore\Bundle\StudioApiBundle\Dto\Asset\Image; | ||
use Pimcore\Model\Asset\Image as CoreImage; | ||
|
||
interface ImageHydratorInterface | ||
{ | ||
public function hydrate(CoreImage $item): Image; | ||
} |
30 changes: 30 additions & 0 deletions
30
src/Service/CoreData/V1/Hydrator/AssetHydratorInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioApiBundle\Service\CoreData\V1\Hydrator; | ||
|
||
use Pimcore\Bundle\StudioApiBundle\Dto\Asset; | ||
use Pimcore\Model\Asset as CoreAsset; | ||
|
||
interface AssetHydratorInterface | ||
{ | ||
/** | ||
* @param CoreAsset $item | ||
* | ||
* @return Asset | ||
*/ | ||
public function hydrate(CoreAsset $item): ?Asset; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Pimcore\Bundle\StudioApiBundle\Service\CoreData\V1\Hydrator; | ||
|
||
use Pimcore\Bundle\StudioApiBundle\Dto\Asset; | ||
use Pimcore\Model\Asset as CoreAsset; | ||
use Symfony\Contracts\Service\ServiceProviderInterface; | ||
|
||
final readonly class AssetHydratorService implements AssetHydratorInterface | ||
{ | ||
public function __construct( | ||
private ServiceProviderInterface $assetHydratorLocator, | ||
) { | ||
} | ||
|
||
public function hydrate(CoreAsset $item): ?Asset | ||
{ | ||
$class = get_class($item); | ||
if($this->assetHydratorLocator->has($class)) { | ||
return $this->assetHydratorLocator->get($class)->hydrate($item); | ||
} | ||
|
||
return null; | ||
//return new Asset($item->getId()); | ||
} | ||
} |
Oops, something went wrong.