Skip to content

Commit

Permalink
add thumbnail normalizer (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat authored Aug 21, 2023
1 parent f1e625d commit 7522189
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
2 changes: 2 additions & 0 deletions config/core_areas/video.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ toolbox:
height: 250
disableProgressReload: true

additional_property_normalizer:
posterPath: ToolboxBundle\Normalizer\ThumbnailNormalizer
4 changes: 4 additions & 0 deletions config/services/normalizer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ services:
- { name: toolbox.property.normalizer }

ToolboxBundle\Normalizer\LinkNormalizer:
tags:
- { name: toolbox.property.normalizer }

ToolboxBundle\Normalizer\ThumbnailNormalizer:
tags:
- { name: toolbox.property.normalizer }
8 changes: 0 additions & 8 deletions src/Normalizer/LinkNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@
namespace ToolboxBundle\Normalizer;

use Pimcore\Model\Document\Editable;
use ToolboxBundle\Manager\ConfigManagerInterface;
use ToolboxBundle\Service\AssetService;

class LinkNormalizer implements PropertyNormalizerInterface
{
public function __construct(
protected ConfigManagerInterface $configManager,
protected AssetService $assetService
) {
}

public function normalize(mixed $value, ?string $toolboxContextId = null): mixed
{
if (!$value instanceof Editable\Link) {
Expand Down
17 changes: 17 additions & 0 deletions src/Normalizer/ThumbnailNormalizer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace ToolboxBundle\Normalizer;

use Pimcore\Model\Asset\Image\Thumbnail;

class ThumbnailNormalizer implements PropertyNormalizerInterface
{
public function normalize(mixed $value, ?string $toolboxContextId = null): mixed
{
if (!$value instanceof Thumbnail) {
return $value;
}

return $value->getPath();
}
}

0 comments on commit 7522189

Please sign in to comment.