Skip to content

Instantly share code, notes, and snippets.

@aertmann
Created December 22, 2014 12:18
Show Gist options
  • Select an option

  • Save aertmann/b1f9ebc5efeb11f49df3 to your computer and use it in GitHub Desktop.

Select an option

Save aertmann/b1f9ebc5efeb11f49df3 to your computer and use it in GitHub Desktop.
<?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