From 930aedc1ab524aadaf2ef1b029a0ab19754a4269 Mon Sep 17 00:00:00 2001 From: Daniel Lienert Date: Fri, 3 Apr 2020 22:09:06 +0200 Subject: [PATCH] FEATURE: Provide icon and description --- Classes/AssetSource/MediaWikiAssetSource.php | 26 ++++++++++++++++++++ Configuration/Settings.yaml | 3 ++- Resources/Public/Wikipedia-logo.svg | 11 +++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Resources/Public/Wikipedia-logo.svg diff --git a/Classes/AssetSource/MediaWikiAssetSource.php b/Classes/AssetSource/MediaWikiAssetSource.php index 83b04e2..4f5d03c 100644 --- a/Classes/AssetSource/MediaWikiAssetSource.php +++ b/Classes/AssetSource/MediaWikiAssetSource.php @@ -10,7 +10,9 @@ * source code. */ +use Neos\Flow\Annotations as Flow; use DL\AssetSource\MediaWiki\Api\MediaWikiClient; +use Neos\Flow\ResourceManagement\ResourceManager; use Neos\Media\Domain\Model\AssetSource\AssetProxyRepositoryInterface; use Neos\Media\Domain\Model\AssetSource\AssetSourceInterface; use Neos\Media\Domain\Model\AssetSource\Neos\NeosAssetProxyRepository; @@ -18,6 +20,12 @@ final class MediaWikiAssetSource implements AssetSourceInterface { + /** + * @Flow\Inject + * @var ResourceManager + */ + protected $resourceManager; + /** * @var MediaWikiClient */ @@ -138,4 +146,22 @@ public function getCopyRightNoticeTemplate(): string { return $this->copyRightNoticeTemplate; } + + /** + * Returns the resource path to Assetsources icon + * + * @return string + */ + public function getIconUri(): string + { + return $this->resourceManager->getPublicPackageResourceUriByPath($this->assetSourceOptions['icon']); + } + + /** + * @return string + */ + public function getDescription(): string + { + return $this->getLabel() . ': ' . $this->getOption('domain'); + } } diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 1d4005d..4019e6f 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -4,8 +4,9 @@ Neos: wikipedia_de: assetSource: 'DL\AssetSource\MediaWiki\AssetSource\MediaWikiAssetSource' assetSourceOptions: - domain: de.wikipedia.org label: Wikipedia (DE) + icon: 'resource://DL.AssetSource.MediaWiki/Public/Wikipedia-logo.svg' + domain: de.wikipedia.org searchStrategy: DL\AssetSource\MediaWiki\Api\SearchStrategies\ArticleSearchStrategy searchStrategyOptions: articleLimit: 10 diff --git a/Resources/Public/Wikipedia-logo.svg b/Resources/Public/Wikipedia-logo.svg new file mode 100644 index 0000000..84f5a8f --- /dev/null +++ b/Resources/Public/Wikipedia-logo.svg @@ -0,0 +1,11 @@ + + + + + + + Wikipedia logo + + +