Created
December 22, 2014 12:18
-
-
Save aertmann/b1f9ebc5efeb11f49df3 to your computer and use it in GitHub Desktop.
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
| <?php | |
| namespace Acme\Package\TypoScript\FlowQueryOperations; | |
| use TYPO3\Eel\FlowQuery\FlowQuery; | |
| use TYPO3\Eel\FlowQuery\Operations\AbstractOperation; | |
| use TYPO3\Flow\Annotations as Flow; | |
| class MediaOperation extends AbstractOperation { | |
| /** | |
| * {@inheritdoc} | |
| * | |
| * @var string | |
| */ | |
| static protected $shortName = 'media'; | |
| /** | |
| * {@inheritdoc} | |
| * | |
| * @var integer | |
| */ | |
| static protected $priority = 100; | |
| /** | |
| * @Flow\Inject | |
| * @var \TYPO3\Media\Domain\Repository\AssetRepository | |
| */ | |
| protected $assetRepository; | |
| /** | |
| * {@inheritdoc} | |
| * | |
| * @param array (or array-like object) $context onto which this operation should be applied | |
| * @return boolean TRUE if the operation can be applied onto the $context, FALSE otherwise | |
| */ | |
| public function canEvaluate($context) { | |
| return TRUE; | |
| } | |
| /** | |
| * @param FlowQuery $flowQuery the FlowQuery object | |
| * @param array $arguments | |
| * @return \TYPO3\Media\Domain\Model\AssetInterface | |
| */ | |
| public function evaluate(FlowQuery $flowQuery, array $arguments) { | |
| $tag = $arguments[0]; | |
| $flowQuery->setContext(array($this->assetRepository->findByTag($tag))); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment