Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <?php
  2. namespace Acme\Package\TypoScript\FlowQueryOperations;
  3.  
  4. use TYPO3\Eel\FlowQuery\FlowQuery;
  5. use TYPO3\Eel\FlowQuery\Operations\AbstractOperation;
  6. use TYPO3\Flow\Annotations as Flow;
  7.  
  8. class MediaOperation extends AbstractOperation {
  9.  
  10. /**
  11. * {@inheritdoc}
  12. *
  13. * @var string
  14. */
  15. static protected $shortName = 'media';
  16.  
  17. /**
  18. * {@inheritdoc}
  19. *
  20. * @var integer
  21. */
  22. static protected $priority = 100;
  23.  
  24. /**
  25. * @Flow\Inject
  26. * @var \TYPO3\Media\Domain\Repository\AssetRepository
  27. */
  28. protected $assetRepository;
  29.  
  30. /**
  31. * {@inheritdoc}
  32. *
  33. * @param array (or array-like object) $context onto which this operation should be applied
  34. * @return boolean TRUE if the operation can be applied onto the $context, FALSE otherwise
  35. */
  36. public function canEvaluate($context) {
  37. return TRUE;
  38. }
  39.  
  40. /**
  41. * @param FlowQuery $flowQuery the FlowQuery object
  42. * @param array $arguments
  43. * @return \TYPO3\Media\Domain\Model\AssetInterface
  44. */
  45. public function evaluate(FlowQuery $flowQuery, array $arguments) {
  46. $tag = $arguments[0];
  47. $flowQuery->setContext(array($this->assetRepository->findByTag($tag)));
  48. }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement