Created
August 12, 2016 09:18
-
-
Save nezaniel/588973194e64c986fc87c703bb4f2d50 to your computer and use it in GitHub Desktop.
A TagBasedAssetListImplementation for Neos TypoScript 2
This file contains hidden or 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
class TagBasedImageListImplementation extends TemplateImplementation { | |
/** | |
* @Flow\Inject | |
* @var TagRepository | |
*/ | |
protected $tagRepository; | |
/** | |
* @Flow\Inject | |
* @var ImageRepository | |
*/ | |
protected $imageRepository; | |
/** | |
* @return ImageInterface[] | |
*/ | |
public function getImages() { | |
$tagIdentifier = $this->tsValue('tag'); | |
if (!empty($tagIdentifier) && ($tag = $this->tagRepository->findByIdentifier($tagIdentifier)) instanceof Tag) { | |
/** @var Tag $tag */ | |
return $this->imageRepository->findByTag($tag); | |
} else { | |
return []; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment