namespace OC\Template;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFolder;
/** @var IURLGenerator */
protected $urlGenerator;
+ /** @var ITimeFactory */
+ protected $timeFactory;
+
/** @var string */
private $iconVarRE = '/--(icon-[a-zA-Z0-9-]+):\s?url\(["\']([a-zA-Z0-9-_\~\/\.\?\=]+)[^;]+;/m';
* @param ILogger $logger
* @param Factory $appDataFactory
* @param IURLGenerator $urlGenerator
+ * @param ITimeFactory $timeFactory
+ * @throws \OCP\Files\NotPermittedException
*/
public function __construct(ILogger $logger,
Factory $appDataFactory,
- IURLGenerator $urlGenerator) {
+ IURLGenerator $urlGenerator,
+ ITimeFactory $timeFactory) {
$this->logger = $logger;
$this->appData = $appDataFactory->get('css');
$this->urlGenerator = $urlGenerator;
+ $this->timeFactory = $timeFactory;
try {
$this->folder = $this->appData->getFolder('icons');
}
public function injectCss() {
+ $mtime = $this->timeFactory->getTime();
+ $file = $this->getCachedCSS();
+ if ($file) {
+ $mtime = $file->getMTime();
+ }
// Only inject once
foreach (\OC_Util::$headers as $header) {
if (
return;
}
}
- $linkToCSS = $this->urlGenerator->linkToRoute('core.Css.getCss', ['appName' => 'icons', 'fileName' => $this->fileName]);
+ $linkToCSS = $this->urlGenerator->linkToRoute('core.Css.getCss', ['appName' => 'icons', 'fileName' => $this->fileName, 'v' => $mtime]);
\OC_Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS], null, true);
}
-}
\ No newline at end of file
+}
use OC\Files\AppData\Factory;
use OC\Template\IconsCacher;
use OCA\Theming\ThemingDefaults;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
protected $appData;
/** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
protected $urlGenerator;
+ /** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
+ private $timeFactory;
protected function setUp() {
$this->logger = $this->createMock(ILogger::class);
$this->appData = $this->createMock(AppData::class);
+ $this->timeFactory = $this->createMock(ITimeFactory::class);
/** @var Factory|\PHPUnit_Framework_MockObject_MockObject $factory */
$factory = $this->createMock(Factory::class);
$this->iconsCacher = new IconsCacher(
$this->logger,
$factory,
- $this->urlGenerator
+ $this->urlGenerator,
+ $this->timeFactory
);
}