/** * Generates entries to place inside web/.htaccess file. * Entries should be placed just after following rule: RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] * * @return string */ public function getWebCode() { $path = rtrim($this->finder->getRealCacheDir(), '/\\'); //@formatter:off return static::HEADER . "RewriteCond %{REQUEST_METHOD} !^(GET|HEAD) [OR]\n" . "RewriteCond %{QUERY_STRING} !^\$\n" . "RewriteRule . - [S=3]\n" . "\n" . "RewriteCond {$path}/\$1/index.html -f\n" . "RewriteRule ^(.*) {$path}/\$1/index.html [L]\n" . "\n" . "RewriteCond {$path}/\$1/index.js -f\n" . "RewriteRule ^(.*) {$path}/\$1/index.js [L]\n" . "\n" . "RewriteCond {$path}/\$1/index.bin -f\n" . "RewriteRule ^(.*) {$path}/\$1/index.bin [L]\n" . static::FOOTER; //@formatter:on }
/** * Saves entry content. If entry exists it will be updated, otherwise created. * * @param CacheElement $element * * @return bool * @throws FilesystemException * @throws SecurityViolationException Specified cache path was found to be dangerous (eg. /../../sandbox) */ public function saveElement(CacheElement $element) { $path = $element->getPath() . '/index.' . $element->getType(); //Type contains extension return $this->finder->writeFile($path, $element->getContent()); }