Skip to content

Commit

Permalink
FEATURE: Assetproxy implements ProvidesOriginalUriInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellienert committed Nov 15, 2020
1 parent 5d1f5bd commit 04a8870
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions Classes/AssetSource/UnsplashAssetProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
use Crew\Unsplash\Photo;
use Neos\Media\Domain\Model\AssetSource\AssetProxy\AssetProxyInterface;
use Neos\Media\Domain\Model\AssetSource\AssetProxy\HasRemoteOriginalInterface;
use Neos\Media\Domain\Model\AssetSource\AssetProxy\ProvidesOriginalUriInterface;
use Neos\Media\Domain\Model\AssetSource\AssetProxy\SupportsIptcMetadataInterface;
use Neos\Media\Domain\Model\AssetSource\AssetSourceInterface;
use Neos\Media\Domain\Model\ImportedAsset;
use Neos\Media\Domain\Repository\ImportedAssetRepository;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Http\Message\UriInterface;

final class UnsplashAssetProxy implements AssetProxyInterface, HasRemoteOriginalInterface, SupportsIptcMetadataInterface
final class UnsplashAssetProxy implements AssetProxyInterface, HasRemoteOriginalInterface, SupportsIptcMetadataInterface, ProvidesOriginalUriInterface
{
/**
* @var Photo
Expand Down Expand Up @@ -182,22 +183,21 @@ public function getHeightInPixels(): ?int
return (int)$this->getProperty('height');
}

/**
* @return null|UriInterface
*/
public function getThumbnailUri(): ?UriInterface
{
return $this->uriFactory->createUri($this->getImageUrl(UnsplashImageSizeInterface::SMALL));
}

/**
* @return null|UriInterface
*/
public function getPreviewUri(): ?UriInterface
{
return $this->uriFactory->createUri($this->getImageUrl(UnsplashImageSizeInterface::REGULAR));
}

public function getOriginalUri(): ?UriInterface
{
return $this->uriFactory->createUri($this->getImageUrl(UnsplashImageSizeInterface::FULL));
}

/**
* @return resource
*/
Expand All @@ -206,9 +206,6 @@ public function getImportStream()
return fopen($this->photo->download(), 'rb');
}

/**
* @return null|string
*/
public function getLocalAssetIdentifier(): ?string
{
return $this->importedAsset instanceof ImportedAsset ? $this->importedAsset->getLocalAssetIdentifier() : '';
Expand All @@ -233,10 +230,6 @@ protected function getProperty(string $propertyName)
return $this->photo->__isset($propertyName) ? $this->photo->__get($propertyName) : null;
}

/**
* @param string $size
* @return string
*/
protected function getImageUrl(string $size): string
{
$urls = $this->getProperty('urls');
Expand Down

0 comments on commit 04a8870

Please sign in to comment.