/** * Initializes the rendering action. * * Use this method to add all static assets. */ public function initializeAction() { if (!$this->cache->has('brushes')) { return; } $themeCss = $this->resolveFilePathReference(sprintf(self::CSS_PATH . '/shCore%s.css', $this->settings['code_snippet']['theme'])); $this->pageRenderer->addCssFile($themeCss); $coreJs = $this->resolveFilePathReference(self::JS_PATH . '/shCore.min.js'); $this->pageRenderer->addJsFooterLibrary('codesnippet_core', $coreJs); $autoloaderJs = $this->resolveFilePathReference(self::JS_PATH . '/shAutoloader.min.js'); $this->pageRenderer->addJsFooterLibrary('codesnippet_autoloader', $autoloaderJs); }
/** * test add JS footer library file */ public function testAddJsFooterLibrary() { $expectedRegExp = '#<script src="fileadmin/test\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#'; $this->fixture->addJsFooterLibrary('test', 'fileadmin/test.js'); $out = $this->fixture->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_FOOTER); $this->assertRegExp($expectedRegExp, $out); }
/** * Render the URI to the resource. The filename is used from child content. * * @param string $file The relative path of the resource (relative to Public resource directory of the extension). */ public function render($file = NULL) { if (!$this->arguments['extensionName']) { $this->arguments['extensionName'] = $this->controllerContext->getRequest()->getControllerExtensionName(); } $uri = 'EXT:' . GeneralUtility::camelCaseToLowerCaseUnderscored($this->arguments['extensionName']) . $this->getResourcesPathAndFilename($file); $uri = GeneralUtility::getFileAbsFileName($uri); $uri = substr($uri, strlen(PATH_site)); switch ($this->arguments['where']) { case 'footer': $this->pageRenderer->addJsFooterFile($uri, $this->arguments['type'], $this->arguments['compress'], $this->arguments['forceOnTop'], $this->arguments['allWrap'], $this->arguments['excludeFromConcatenation']); break; case 'footerLibs': $this->pageRenderer->addJsFooterLibrary($this->arguments['key'], $uri, $this->arguments['type'], $this->arguments['compress'], $this->arguments['forceOnTop'], $this->arguments['allWrap'], $this->arguments['excludeFromConcatenation']); break; default: $this->pageRenderer->addJsFile($uri, $this->arguments['type'], $this->arguments['compress'], $this->arguments['forceOnTop'], $this->arguments['allWrap'], $this->arguments['excludeFromConcatenation']); break; } }