Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
namespace Netlogix\Blog\Aspect;
/* *
* This script belongs to the TYPO3 Flow package "TYPO3.Neos". *
* *
* It is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License, either version 3 of the *
* License, or (at your option) any later version. *
* *
* The TYPO3 project - inspiring people to share! *
* */
use TYPO3\Flow\Annotations as Flow;
/**
* @Flow\Aspect
*/
class ModificationTimeAspect {
/**
* @Flow\Around("method(TYPO3\Fluid\ViewHelpers\Uri\ResourceViewHelper->render())")
* @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current joinpoint
* @return string The result of the target method if it has not been intercepted
*/
public function addModificationTime(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint) {
$result = $joinPoint->getAdviceChain()->proceed($joinPoint);
if ($joinPoint->getMethodArgument('resource') !== NULL) {
return $result;
}
if (strpos($joinPoint->getMethodArgument('path'), 'resource://') === 0) {
$resourcePath = $joinPoint->getMethodArgument('path');
} else if ($joinPoint->getMethodArgument('package') !== NULL) {
$resourcePath = 'resource://' . $joinPoint->getMethodArgument('package') . '/Public/' . $joinPoint->getMethodArgument('path');
} else {
return $result;
}
if (!is_dir($resourcePath)) {
try {
if (strpos($result, '?') === FALSE) {
$result = $result . '?' . filemtime($resourcePath);
} else {
$result = $result . '&' . filemtime($resourcePath);
}
} catch (\Exception $e) {
}
}
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment